|
1
|
# Generated TypeScript README |
|
2
|
This README will guide you through the process of using the generated JavaScript SDK package for the connector `example`. It will also provide examples on how to use your generated SDK to call your Data Connect queries and mutations. |
|
3
|
|
|
4
|
**If you're looking for the `React README`, you can find it at [`dataconnect-generated/react/README.md`](./react/README.md)** |
|
5
|
|
|
6
|
***NOTE:** This README is generated alongside the generated SDK. If you make changes to this file, they will be overwritten when the SDK is regenerated.* |
|
7
|
|
|
8
|
# Table of Contents |
|
9
|
- [**Overview**](#generated-javascript-readme) |
|
10
|
- [**Accessing the connector**](#accessing-the-connector) |
|
11
|
- [*Connecting to the local Emulator*](#connecting-to-the-local-emulator) |
|
12
|
- [**Queries**](#queries) |
|
13
|
- [*GetCategory*](#getcategory) |
|
14
|
- [*ListCategories*](#listcategories) |
|
15
|
- [*GetDevice*](#getdevice) |
|
16
|
- [*ListDevices*](#listdevices) |
|
17
|
- [*GetGuide*](#getguide) |
|
18
|
- [*ListGuides*](#listguides) |
|
19
|
- [*GetPart*](#getpart) |
|
20
|
- [*ListParts*](#listparts) |
|
21
|
- [*GetStep*](#getstep) |
|
22
|
- [*ListSteps*](#liststeps) |
|
23
|
- [*GetMyBookmarks*](#getmybookmarks) |
|
24
|
- [*GetBookmark*](#getbookmark) |
|
25
|
- [**Mutations**](#mutations) |
|
26
|
- [*CreateCategory*](#createcategory) |
|
27
|
- [*UpsertCategory*](#upsertcategory) |
|
28
|
- [*DeleteCategory*](#deletecategory) |
|
29
|
- [*UpdateCategory*](#updatecategory) |
|
30
|
- [*CreateDevice*](#createdevice) |
|
31
|
- [*UpsertDevice*](#upsertdevice) |
|
32
|
- [*DeleteDevice*](#deletedevice) |
|
33
|
- [*UpdateDevice*](#updatedevice) |
|
34
|
- [*CreateGuide*](#createguide) |
|
35
|
- [*UpsertGuide*](#upsertguide) |
|
36
|
- [*DeleteGuide*](#deleteguide) |
|
37
|
- [*UpdateGuide*](#updateguide) |
|
38
|
- [*CreatePart*](#createpart) |
|
39
|
- [*UpsertPart*](#upsertpart) |
|
40
|
- [*DeletePart*](#deletepart) |
|
41
|
- [*UpdatePart*](#updatepart) |
|
42
|
- [*CreateStep*](#createstep) |
|
43
|
- [*UpsertStep*](#upsertstep) |
|
44
|
- [*DeleteStep*](#deletestep) |
|
45
|
- [*UpdateStep*](#updatestep) |
|
46
|
- [*CreateBookmark*](#createbookmark) |
|
47
|
- [*UpsertBookmark*](#upsertbookmark) |
|
48
|
- [*DeleteBookmark*](#deletebookmark) |
|
49
|
- [*UpdateBookmark*](#updatebookmark) |
|
50
|
|
|
51
|
# Accessing the connector |
|
52
|
A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector `example`. You can find more information about connectors in the [Data Connect documentation](https://firebase.google.com/docs/data-connect#how-does). |
|
53
|
|
|
54
|
You can use this generated SDK by importing from the package `@dataconnect/generated` as shown below. Both CommonJS and ESM imports are supported. |
|
55
|
|
|
56
|
You can also follow the instructions from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#set-client). |
|
57
|
|
|
58
|
```typescript |
|
59
|
import { getDataConnect } from 'firebase/data-connect'; |
|
60
|
import { connectorConfig } from '@dataconnect/generated'; |
|
61
|
|
|
62
|
const dataConnect = getDataConnect(connectorConfig); |
|
63
|
``` |
|
64
|
|
|
65
|
## Connecting to the local Emulator |
|
66
|
By default, the connector will connect to the production service. |
|
67
|
|
|
68
|
To connect to the emulator, you can use the following code. |
|
69
|
You can also follow the emulator instructions from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#instrument-clients). |
|
70
|
|
|
71
|
```typescript |
|
72
|
import { connectDataConnectEmulator, getDataConnect } from 'firebase/data-connect'; |
|
73
|
import { connectorConfig } from '@dataconnect/generated'; |
|
74
|
|
|
75
|
const dataConnect = getDataConnect(connectorConfig); |
|
76
|
connectDataConnectEmulator(dataConnect, 'localhost', 9399); |
|
77
|
``` |
|
78
|
|
|
79
|
After it's initialized, you can call your Data Connect [queries](#queries) and [mutations](#mutations) from your generated SDK. |
|
80
|
|
|
81
|
# Queries |
|
82
|
|
|
83
|
There are two ways to execute a Data Connect Query using the generated Web SDK: |
|
84
|
- Using a Query Reference function, which returns a `QueryRef` |
|
85
|
- The `QueryRef` can be used as an argument to `executeQuery()`, which will execute the Query and return a `QueryPromise` |
|
86
|
- Using an action shortcut function, which returns a `QueryPromise` |
|
87
|
- Calling the action shortcut function will execute the Query and return a `QueryPromise` |
|
88
|
|
|
89
|
The following is true for both the action shortcut function and the `QueryRef` function: |
|
90
|
- The `QueryPromise` returned will resolve to the result of the Query once it has finished executing |
|
91
|
- If the Query accepts arguments, both the action shortcut function and the `QueryRef` function accept a single argument: an object that contains all the required variables (and the optional variables) for the Query |
|
92
|
- Both functions can be called with or without passing in a `DataConnect` instance as an argument. If no `DataConnect` argument is passed in, then the generated SDK will call `getDataConnect(connectorConfig)` behind the scenes for you. |
|
93
|
|
|
94
|
Below are examples of how to use the `example` connector's generated functions to execute each query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-queries). |
|
95
|
|
|
96
|
## GetCategory |
|
97
|
You can execute the `GetCategory` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
98
|
```typescript |
|
99
|
getCategory(vars: GetCategoryVariables, options?: ExecuteQueryOptions): QueryPromise<GetCategoryData, GetCategoryVariables>; |
|
100
|
|
|
101
|
interface GetCategoryRef { |
|
102
|
... |
|
103
|
/* Allow users to create refs without passing in DataConnect */ |
|
104
|
(vars: GetCategoryVariables): QueryRef<GetCategoryData, GetCategoryVariables>; |
|
105
|
} |
|
106
|
export const getCategoryRef: GetCategoryRef; |
|
107
|
``` |
|
108
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
109
|
```typescript |
|
110
|
getCategory(dc: DataConnect, vars: GetCategoryVariables, options?: ExecuteQueryOptions): QueryPromise<GetCategoryData, GetCategoryVariables>; |
|
111
|
|
|
112
|
interface GetCategoryRef { |
|
113
|
... |
|
114
|
(dc: DataConnect, vars: GetCategoryVariables): QueryRef<GetCategoryData, GetCategoryVariables>; |
|
115
|
} |
|
116
|
export const getCategoryRef: GetCategoryRef; |
|
117
|
``` |
|
118
|
|
|
119
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getCategoryRef: |
|
120
|
```typescript |
|
121
|
const name = getCategoryRef.operationName; |
|
122
|
console.log(name); |
|
123
|
``` |
|
124
|
|
|
125
|
### Variables |
|
126
|
The `GetCategory` query requires an argument of type `GetCategoryVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
127
|
|
|
128
|
```typescript |
|
129
|
export interface GetCategoryVariables { |
|
130
|
id: UUIDString; |
|
131
|
} |
|
132
|
``` |
|
133
|
### Return Type |
|
134
|
Recall that executing the `GetCategory` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
135
|
|
|
136
|
The `data` property is an object of type `GetCategoryData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
137
|
```typescript |
|
138
|
export interface GetCategoryData { |
|
139
|
category?: { |
|
140
|
name: string; |
|
141
|
}; |
|
142
|
} |
|
143
|
``` |
|
144
|
### Using `GetCategory`'s action shortcut function |
|
145
|
|
|
146
|
```typescript |
|
147
|
import { getDataConnect } from 'firebase/data-connect'; |
|
148
|
import { connectorConfig, getCategory, GetCategoryVariables } from '@dataconnect/generated'; |
|
149
|
|
|
150
|
// The `GetCategory` query requires an argument of type `GetCategoryVariables`: |
|
151
|
const getCategoryVars: GetCategoryVariables = { |
|
152
|
id: ..., |
|
153
|
}; |
|
154
|
|
|
155
|
// Call the `getCategory()` function to execute the query. |
|
156
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
157
|
const { data } = await getCategory(getCategoryVars); |
|
158
|
// Variables can be defined inline as well. |
|
159
|
const { data } = await getCategory({ id: ..., }); |
|
160
|
|
|
161
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
162
|
const dataConnect = getDataConnect(connectorConfig); |
|
163
|
const { data } = await getCategory(dataConnect, getCategoryVars); |
|
164
|
|
|
165
|
console.log(data.category); |
|
166
|
|
|
167
|
// Or, you can use the `Promise` API. |
|
168
|
getCategory(getCategoryVars).then((response) => { |
|
169
|
const data = response.data; |
|
170
|
console.log(data.category); |
|
171
|
}); |
|
172
|
``` |
|
173
|
|
|
174
|
### Using `GetCategory`'s `QueryRef` function |
|
175
|
|
|
176
|
```typescript |
|
177
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
178
|
import { connectorConfig, getCategoryRef, GetCategoryVariables } from '@dataconnect/generated'; |
|
179
|
|
|
180
|
// The `GetCategory` query requires an argument of type `GetCategoryVariables`: |
|
181
|
const getCategoryVars: GetCategoryVariables = { |
|
182
|
id: ..., |
|
183
|
}; |
|
184
|
|
|
185
|
// Call the `getCategoryRef()` function to get a reference to the query. |
|
186
|
const ref = getCategoryRef(getCategoryVars); |
|
187
|
// Variables can be defined inline as well. |
|
188
|
const ref = getCategoryRef({ id: ..., }); |
|
189
|
|
|
190
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
191
|
const dataConnect = getDataConnect(connectorConfig); |
|
192
|
const ref = getCategoryRef(dataConnect, getCategoryVars); |
|
193
|
|
|
194
|
// Call `executeQuery()` on the reference to execute the query. |
|
195
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
196
|
const { data } = await executeQuery(ref); |
|
197
|
|
|
198
|
console.log(data.category); |
|
199
|
|
|
200
|
// Or, you can use the `Promise` API. |
|
201
|
executeQuery(ref).then((response) => { |
|
202
|
const data = response.data; |
|
203
|
console.log(data.category); |
|
204
|
}); |
|
205
|
``` |
|
206
|
|
|
207
|
## ListCategories |
|
208
|
You can execute the `ListCategories` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
209
|
```typescript |
|
210
|
listCategories(options?: ExecuteQueryOptions): QueryPromise<ListCategoriesData, undefined>; |
|
211
|
|
|
212
|
interface ListCategoriesRef { |
|
213
|
... |
|
214
|
/* Allow users to create refs without passing in DataConnect */ |
|
215
|
(): QueryRef<ListCategoriesData, undefined>; |
|
216
|
} |
|
217
|
export const listCategoriesRef: ListCategoriesRef; |
|
218
|
``` |
|
219
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
220
|
```typescript |
|
221
|
listCategories(dc: DataConnect, options?: ExecuteQueryOptions): QueryPromise<ListCategoriesData, undefined>; |
|
222
|
|
|
223
|
interface ListCategoriesRef { |
|
224
|
... |
|
225
|
(dc: DataConnect): QueryRef<ListCategoriesData, undefined>; |
|
226
|
} |
|
227
|
export const listCategoriesRef: ListCategoriesRef; |
|
228
|
``` |
|
229
|
|
|
230
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listCategoriesRef: |
|
231
|
```typescript |
|
232
|
const name = listCategoriesRef.operationName; |
|
233
|
console.log(name); |
|
234
|
``` |
|
235
|
|
|
236
|
### Variables |
|
237
|
The `ListCategories` query has no variables. |
|
238
|
### Return Type |
|
239
|
Recall that executing the `ListCategories` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
240
|
|
|
241
|
The `data` property is an object of type `ListCategoriesData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
242
|
```typescript |
|
243
|
export interface ListCategoriesData { |
|
244
|
categories: ({ |
|
245
|
name: string; |
|
246
|
})[]; |
|
247
|
} |
|
248
|
``` |
|
249
|
### Using `ListCategories`'s action shortcut function |
|
250
|
|
|
251
|
```typescript |
|
252
|
import { getDataConnect } from 'firebase/data-connect'; |
|
253
|
import { connectorConfig, listCategories } from '@dataconnect/generated'; |
|
254
|
|
|
255
|
|
|
256
|
// Call the `listCategories()` function to execute the query. |
|
257
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
258
|
const { data } = await listCategories(); |
|
259
|
|
|
260
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
261
|
const dataConnect = getDataConnect(connectorConfig); |
|
262
|
const { data } = await listCategories(dataConnect); |
|
263
|
|
|
264
|
console.log(data.categories); |
|
265
|
|
|
266
|
// Or, you can use the `Promise` API. |
|
267
|
listCategories().then((response) => { |
|
268
|
const data = response.data; |
|
269
|
console.log(data.categories); |
|
270
|
}); |
|
271
|
``` |
|
272
|
|
|
273
|
### Using `ListCategories`'s `QueryRef` function |
|
274
|
|
|
275
|
```typescript |
|
276
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
277
|
import { connectorConfig, listCategoriesRef } from '@dataconnect/generated'; |
|
278
|
|
|
279
|
|
|
280
|
// Call the `listCategoriesRef()` function to get a reference to the query. |
|
281
|
const ref = listCategoriesRef(); |
|
282
|
|
|
283
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
284
|
const dataConnect = getDataConnect(connectorConfig); |
|
285
|
const ref = listCategoriesRef(dataConnect); |
|
286
|
|
|
287
|
// Call `executeQuery()` on the reference to execute the query. |
|
288
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
289
|
const { data } = await executeQuery(ref); |
|
290
|
|
|
291
|
console.log(data.categories); |
|
292
|
|
|
293
|
// Or, you can use the `Promise` API. |
|
294
|
executeQuery(ref).then((response) => { |
|
295
|
const data = response.data; |
|
296
|
console.log(data.categories); |
|
297
|
}); |
|
298
|
``` |
|
299
|
|
|
300
|
## GetDevice |
|
301
|
You can execute the `GetDevice` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
302
|
```typescript |
|
303
|
getDevice(vars: GetDeviceVariables, options?: ExecuteQueryOptions): QueryPromise<GetDeviceData, GetDeviceVariables>; |
|
304
|
|
|
305
|
interface GetDeviceRef { |
|
306
|
... |
|
307
|
/* Allow users to create refs without passing in DataConnect */ |
|
308
|
(vars: GetDeviceVariables): QueryRef<GetDeviceData, GetDeviceVariables>; |
|
309
|
} |
|
310
|
export const getDeviceRef: GetDeviceRef; |
|
311
|
``` |
|
312
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
313
|
```typescript |
|
314
|
getDevice(dc: DataConnect, vars: GetDeviceVariables, options?: ExecuteQueryOptions): QueryPromise<GetDeviceData, GetDeviceVariables>; |
|
315
|
|
|
316
|
interface GetDeviceRef { |
|
317
|
... |
|
318
|
(dc: DataConnect, vars: GetDeviceVariables): QueryRef<GetDeviceData, GetDeviceVariables>; |
|
319
|
} |
|
320
|
export const getDeviceRef: GetDeviceRef; |
|
321
|
``` |
|
322
|
|
|
323
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getDeviceRef: |
|
324
|
```typescript |
|
325
|
const name = getDeviceRef.operationName; |
|
326
|
console.log(name); |
|
327
|
``` |
|
328
|
|
|
329
|
### Variables |
|
330
|
The `GetDevice` query requires an argument of type `GetDeviceVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
331
|
|
|
332
|
```typescript |
|
333
|
export interface GetDeviceVariables { |
|
334
|
id: UUIDString; |
|
335
|
} |
|
336
|
``` |
|
337
|
### Return Type |
|
338
|
Recall that executing the `GetDevice` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
339
|
|
|
340
|
The `data` property is an object of type `GetDeviceData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
341
|
```typescript |
|
342
|
export interface GetDeviceData { |
|
343
|
device?: { |
|
344
|
modelName: string; |
|
345
|
}; |
|
346
|
} |
|
347
|
``` |
|
348
|
### Using `GetDevice`'s action shortcut function |
|
349
|
|
|
350
|
```typescript |
|
351
|
import { getDataConnect } from 'firebase/data-connect'; |
|
352
|
import { connectorConfig, getDevice, GetDeviceVariables } from '@dataconnect/generated'; |
|
353
|
|
|
354
|
// The `GetDevice` query requires an argument of type `GetDeviceVariables`: |
|
355
|
const getDeviceVars: GetDeviceVariables = { |
|
356
|
id: ..., |
|
357
|
}; |
|
358
|
|
|
359
|
// Call the `getDevice()` function to execute the query. |
|
360
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
361
|
const { data } = await getDevice(getDeviceVars); |
|
362
|
// Variables can be defined inline as well. |
|
363
|
const { data } = await getDevice({ id: ..., }); |
|
364
|
|
|
365
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
366
|
const dataConnect = getDataConnect(connectorConfig); |
|
367
|
const { data } = await getDevice(dataConnect, getDeviceVars); |
|
368
|
|
|
369
|
console.log(data.device); |
|
370
|
|
|
371
|
// Or, you can use the `Promise` API. |
|
372
|
getDevice(getDeviceVars).then((response) => { |
|
373
|
const data = response.data; |
|
374
|
console.log(data.device); |
|
375
|
}); |
|
376
|
``` |
|
377
|
|
|
378
|
### Using `GetDevice`'s `QueryRef` function |
|
379
|
|
|
380
|
```typescript |
|
381
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
382
|
import { connectorConfig, getDeviceRef, GetDeviceVariables } from '@dataconnect/generated'; |
|
383
|
|
|
384
|
// The `GetDevice` query requires an argument of type `GetDeviceVariables`: |
|
385
|
const getDeviceVars: GetDeviceVariables = { |
|
386
|
id: ..., |
|
387
|
}; |
|
388
|
|
|
389
|
// Call the `getDeviceRef()` function to get a reference to the query. |
|
390
|
const ref = getDeviceRef(getDeviceVars); |
|
391
|
// Variables can be defined inline as well. |
|
392
|
const ref = getDeviceRef({ id: ..., }); |
|
393
|
|
|
394
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
395
|
const dataConnect = getDataConnect(connectorConfig); |
|
396
|
const ref = getDeviceRef(dataConnect, getDeviceVars); |
|
397
|
|
|
398
|
// Call `executeQuery()` on the reference to execute the query. |
|
399
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
400
|
const { data } = await executeQuery(ref); |
|
401
|
|
|
402
|
console.log(data.device); |
|
403
|
|
|
404
|
// Or, you can use the `Promise` API. |
|
405
|
executeQuery(ref).then((response) => { |
|
406
|
const data = response.data; |
|
407
|
console.log(data.device); |
|
408
|
}); |
|
409
|
``` |
|
410
|
|
|
411
|
## ListDevices |
|
412
|
You can execute the `ListDevices` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
413
|
```typescript |
|
414
|
listDevices(options?: ExecuteQueryOptions): QueryPromise<ListDevicesData, undefined>; |
|
415
|
|
|
416
|
interface ListDevicesRef { |
|
417
|
... |
|
418
|
/* Allow users to create refs without passing in DataConnect */ |
|
419
|
(): QueryRef<ListDevicesData, undefined>; |
|
420
|
} |
|
421
|
export const listDevicesRef: ListDevicesRef; |
|
422
|
``` |
|
423
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
424
|
```typescript |
|
425
|
listDevices(dc: DataConnect, options?: ExecuteQueryOptions): QueryPromise<ListDevicesData, undefined>; |
|
426
|
|
|
427
|
interface ListDevicesRef { |
|
428
|
... |
|
429
|
(dc: DataConnect): QueryRef<ListDevicesData, undefined>; |
|
430
|
} |
|
431
|
export const listDevicesRef: ListDevicesRef; |
|
432
|
``` |
|
433
|
|
|
434
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listDevicesRef: |
|
435
|
```typescript |
|
436
|
const name = listDevicesRef.operationName; |
|
437
|
console.log(name); |
|
438
|
``` |
|
439
|
|
|
440
|
### Variables |
|
441
|
The `ListDevices` query has no variables. |
|
442
|
### Return Type |
|
443
|
Recall that executing the `ListDevices` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
444
|
|
|
445
|
The `data` property is an object of type `ListDevicesData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
446
|
```typescript |
|
447
|
export interface ListDevicesData { |
|
448
|
devices: ({ |
|
449
|
modelName: string; |
|
450
|
})[]; |
|
451
|
} |
|
452
|
``` |
|
453
|
### Using `ListDevices`'s action shortcut function |
|
454
|
|
|
455
|
```typescript |
|
456
|
import { getDataConnect } from 'firebase/data-connect'; |
|
457
|
import { connectorConfig, listDevices } from '@dataconnect/generated'; |
|
458
|
|
|
459
|
|
|
460
|
// Call the `listDevices()` function to execute the query. |
|
461
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
462
|
const { data } = await listDevices(); |
|
463
|
|
|
464
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
465
|
const dataConnect = getDataConnect(connectorConfig); |
|
466
|
const { data } = await listDevices(dataConnect); |
|
467
|
|
|
468
|
console.log(data.devices); |
|
469
|
|
|
470
|
// Or, you can use the `Promise` API. |
|
471
|
listDevices().then((response) => { |
|
472
|
const data = response.data; |
|
473
|
console.log(data.devices); |
|
474
|
}); |
|
475
|
``` |
|
476
|
|
|
477
|
### Using `ListDevices`'s `QueryRef` function |
|
478
|
|
|
479
|
```typescript |
|
480
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
481
|
import { connectorConfig, listDevicesRef } from '@dataconnect/generated'; |
|
482
|
|
|
483
|
|
|
484
|
// Call the `listDevicesRef()` function to get a reference to the query. |
|
485
|
const ref = listDevicesRef(); |
|
486
|
|
|
487
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
488
|
const dataConnect = getDataConnect(connectorConfig); |
|
489
|
const ref = listDevicesRef(dataConnect); |
|
490
|
|
|
491
|
// Call `executeQuery()` on the reference to execute the query. |
|
492
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
493
|
const { data } = await executeQuery(ref); |
|
494
|
|
|
495
|
console.log(data.devices); |
|
496
|
|
|
497
|
// Or, you can use the `Promise` API. |
|
498
|
executeQuery(ref).then((response) => { |
|
499
|
const data = response.data; |
|
500
|
console.log(data.devices); |
|
501
|
}); |
|
502
|
``` |
|
503
|
|
|
504
|
## GetGuide |
|
505
|
You can execute the `GetGuide` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
506
|
```typescript |
|
507
|
getGuide(vars: GetGuideVariables, options?: ExecuteQueryOptions): QueryPromise<GetGuideData, GetGuideVariables>; |
|
508
|
|
|
509
|
interface GetGuideRef { |
|
510
|
... |
|
511
|
/* Allow users to create refs without passing in DataConnect */ |
|
512
|
(vars: GetGuideVariables): QueryRef<GetGuideData, GetGuideVariables>; |
|
513
|
} |
|
514
|
export const getGuideRef: GetGuideRef; |
|
515
|
``` |
|
516
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
517
|
```typescript |
|
518
|
getGuide(dc: DataConnect, vars: GetGuideVariables, options?: ExecuteQueryOptions): QueryPromise<GetGuideData, GetGuideVariables>; |
|
519
|
|
|
520
|
interface GetGuideRef { |
|
521
|
... |
|
522
|
(dc: DataConnect, vars: GetGuideVariables): QueryRef<GetGuideData, GetGuideVariables>; |
|
523
|
} |
|
524
|
export const getGuideRef: GetGuideRef; |
|
525
|
``` |
|
526
|
|
|
527
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getGuideRef: |
|
528
|
```typescript |
|
529
|
const name = getGuideRef.operationName; |
|
530
|
console.log(name); |
|
531
|
``` |
|
532
|
|
|
533
|
### Variables |
|
534
|
The `GetGuide` query requires an argument of type `GetGuideVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
535
|
|
|
536
|
```typescript |
|
537
|
export interface GetGuideVariables { |
|
538
|
id: UUIDString; |
|
539
|
} |
|
540
|
``` |
|
541
|
### Return Type |
|
542
|
Recall that executing the `GetGuide` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
543
|
|
|
544
|
The `data` property is an object of type `GetGuideData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
545
|
```typescript |
|
546
|
export interface GetGuideData { |
|
547
|
guide?: { |
|
548
|
title: string; |
|
549
|
}; |
|
550
|
} |
|
551
|
``` |
|
552
|
### Using `GetGuide`'s action shortcut function |
|
553
|
|
|
554
|
```typescript |
|
555
|
import { getDataConnect } from 'firebase/data-connect'; |
|
556
|
import { connectorConfig, getGuide, GetGuideVariables } from '@dataconnect/generated'; |
|
557
|
|
|
558
|
// The `GetGuide` query requires an argument of type `GetGuideVariables`: |
|
559
|
const getGuideVars: GetGuideVariables = { |
|
560
|
id: ..., |
|
561
|
}; |
|
562
|
|
|
563
|
// Call the `getGuide()` function to execute the query. |
|
564
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
565
|
const { data } = await getGuide(getGuideVars); |
|
566
|
// Variables can be defined inline as well. |
|
567
|
const { data } = await getGuide({ id: ..., }); |
|
568
|
|
|
569
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
570
|
const dataConnect = getDataConnect(connectorConfig); |
|
571
|
const { data } = await getGuide(dataConnect, getGuideVars); |
|
572
|
|
|
573
|
console.log(data.guide); |
|
574
|
|
|
575
|
// Or, you can use the `Promise` API. |
|
576
|
getGuide(getGuideVars).then((response) => { |
|
577
|
const data = response.data; |
|
578
|
console.log(data.guide); |
|
579
|
}); |
|
580
|
``` |
|
581
|
|
|
582
|
### Using `GetGuide`'s `QueryRef` function |
|
583
|
|
|
584
|
```typescript |
|
585
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
586
|
import { connectorConfig, getGuideRef, GetGuideVariables } from '@dataconnect/generated'; |
|
587
|
|
|
588
|
// The `GetGuide` query requires an argument of type `GetGuideVariables`: |
|
589
|
const getGuideVars: GetGuideVariables = { |
|
590
|
id: ..., |
|
591
|
}; |
|
592
|
|
|
593
|
// Call the `getGuideRef()` function to get a reference to the query. |
|
594
|
const ref = getGuideRef(getGuideVars); |
|
595
|
// Variables can be defined inline as well. |
|
596
|
const ref = getGuideRef({ id: ..., }); |
|
597
|
|
|
598
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
599
|
const dataConnect = getDataConnect(connectorConfig); |
|
600
|
const ref = getGuideRef(dataConnect, getGuideVars); |
|
601
|
|
|
602
|
// Call `executeQuery()` on the reference to execute the query. |
|
603
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
604
|
const { data } = await executeQuery(ref); |
|
605
|
|
|
606
|
console.log(data.guide); |
|
607
|
|
|
608
|
// Or, you can use the `Promise` API. |
|
609
|
executeQuery(ref).then((response) => { |
|
610
|
const data = response.data; |
|
611
|
console.log(data.guide); |
|
612
|
}); |
|
613
|
``` |
|
614
|
|
|
615
|
## ListGuides |
|
616
|
You can execute the `ListGuides` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
617
|
```typescript |
|
618
|
listGuides(options?: ExecuteQueryOptions): QueryPromise<ListGuidesData, undefined>; |
|
619
|
|
|
620
|
interface ListGuidesRef { |
|
621
|
... |
|
622
|
/* Allow users to create refs without passing in DataConnect */ |
|
623
|
(): QueryRef<ListGuidesData, undefined>; |
|
624
|
} |
|
625
|
export const listGuidesRef: ListGuidesRef; |
|
626
|
``` |
|
627
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
628
|
```typescript |
|
629
|
listGuides(dc: DataConnect, options?: ExecuteQueryOptions): QueryPromise<ListGuidesData, undefined>; |
|
630
|
|
|
631
|
interface ListGuidesRef { |
|
632
|
... |
|
633
|
(dc: DataConnect): QueryRef<ListGuidesData, undefined>; |
|
634
|
} |
|
635
|
export const listGuidesRef: ListGuidesRef; |
|
636
|
``` |
|
637
|
|
|
638
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listGuidesRef: |
|
639
|
```typescript |
|
640
|
const name = listGuidesRef.operationName; |
|
641
|
console.log(name); |
|
642
|
``` |
|
643
|
|
|
644
|
### Variables |
|
645
|
The `ListGuides` query has no variables. |
|
646
|
### Return Type |
|
647
|
Recall that executing the `ListGuides` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
648
|
|
|
649
|
The `data` property is an object of type `ListGuidesData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
650
|
```typescript |
|
651
|
export interface ListGuidesData { |
|
652
|
guides: ({ |
|
653
|
title: string; |
|
654
|
})[]; |
|
655
|
} |
|
656
|
``` |
|
657
|
### Using `ListGuides`'s action shortcut function |
|
658
|
|
|
659
|
```typescript |
|
660
|
import { getDataConnect } from 'firebase/data-connect'; |
|
661
|
import { connectorConfig, listGuides } from '@dataconnect/generated'; |
|
662
|
|
|
663
|
|
|
664
|
// Call the `listGuides()` function to execute the query. |
|
665
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
666
|
const { data } = await listGuides(); |
|
667
|
|
|
668
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
669
|
const dataConnect = getDataConnect(connectorConfig); |
|
670
|
const { data } = await listGuides(dataConnect); |
|
671
|
|
|
672
|
console.log(data.guides); |
|
673
|
|
|
674
|
// Or, you can use the `Promise` API. |
|
675
|
listGuides().then((response) => { |
|
676
|
const data = response.data; |
|
677
|
console.log(data.guides); |
|
678
|
}); |
|
679
|
``` |
|
680
|
|
|
681
|
### Using `ListGuides`'s `QueryRef` function |
|
682
|
|
|
683
|
```typescript |
|
684
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
685
|
import { connectorConfig, listGuidesRef } from '@dataconnect/generated'; |
|
686
|
|
|
687
|
|
|
688
|
// Call the `listGuidesRef()` function to get a reference to the query. |
|
689
|
const ref = listGuidesRef(); |
|
690
|
|
|
691
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
692
|
const dataConnect = getDataConnect(connectorConfig); |
|
693
|
const ref = listGuidesRef(dataConnect); |
|
694
|
|
|
695
|
// Call `executeQuery()` on the reference to execute the query. |
|
696
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
697
|
const { data } = await executeQuery(ref); |
|
698
|
|
|
699
|
console.log(data.guides); |
|
700
|
|
|
701
|
// Or, you can use the `Promise` API. |
|
702
|
executeQuery(ref).then((response) => { |
|
703
|
const data = response.data; |
|
704
|
console.log(data.guides); |
|
705
|
}); |
|
706
|
``` |
|
707
|
|
|
708
|
## GetPart |
|
709
|
You can execute the `GetPart` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
710
|
```typescript |
|
711
|
getPart(vars: GetPartVariables, options?: ExecuteQueryOptions): QueryPromise<GetPartData, GetPartVariables>; |
|
712
|
|
|
713
|
interface GetPartRef { |
|
714
|
... |
|
715
|
/* Allow users to create refs without passing in DataConnect */ |
|
716
|
(vars: GetPartVariables): QueryRef<GetPartData, GetPartVariables>; |
|
717
|
} |
|
718
|
export const getPartRef: GetPartRef; |
|
719
|
``` |
|
720
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
721
|
```typescript |
|
722
|
getPart(dc: DataConnect, vars: GetPartVariables, options?: ExecuteQueryOptions): QueryPromise<GetPartData, GetPartVariables>; |
|
723
|
|
|
724
|
interface GetPartRef { |
|
725
|
... |
|
726
|
(dc: DataConnect, vars: GetPartVariables): QueryRef<GetPartData, GetPartVariables>; |
|
727
|
} |
|
728
|
export const getPartRef: GetPartRef; |
|
729
|
``` |
|
730
|
|
|
731
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getPartRef: |
|
732
|
```typescript |
|
733
|
const name = getPartRef.operationName; |
|
734
|
console.log(name); |
|
735
|
``` |
|
736
|
|
|
737
|
### Variables |
|
738
|
The `GetPart` query requires an argument of type `GetPartVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
739
|
|
|
740
|
```typescript |
|
741
|
export interface GetPartVariables { |
|
742
|
id: UUIDString; |
|
743
|
} |
|
744
|
``` |
|
745
|
### Return Type |
|
746
|
Recall that executing the `GetPart` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
747
|
|
|
748
|
The `data` property is an object of type `GetPartData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
749
|
```typescript |
|
750
|
export interface GetPartData { |
|
751
|
part?: { |
|
752
|
partName: string; |
|
753
|
}; |
|
754
|
} |
|
755
|
``` |
|
756
|
### Using `GetPart`'s action shortcut function |
|
757
|
|
|
758
|
```typescript |
|
759
|
import { getDataConnect } from 'firebase/data-connect'; |
|
760
|
import { connectorConfig, getPart, GetPartVariables } from '@dataconnect/generated'; |
|
761
|
|
|
762
|
// The `GetPart` query requires an argument of type `GetPartVariables`: |
|
763
|
const getPartVars: GetPartVariables = { |
|
764
|
id: ..., |
|
765
|
}; |
|
766
|
|
|
767
|
// Call the `getPart()` function to execute the query. |
|
768
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
769
|
const { data } = await getPart(getPartVars); |
|
770
|
// Variables can be defined inline as well. |
|
771
|
const { data } = await getPart({ id: ..., }); |
|
772
|
|
|
773
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
774
|
const dataConnect = getDataConnect(connectorConfig); |
|
775
|
const { data } = await getPart(dataConnect, getPartVars); |
|
776
|
|
|
777
|
console.log(data.part); |
|
778
|
|
|
779
|
// Or, you can use the `Promise` API. |
|
780
|
getPart(getPartVars).then((response) => { |
|
781
|
const data = response.data; |
|
782
|
console.log(data.part); |
|
783
|
}); |
|
784
|
``` |
|
785
|
|
|
786
|
### Using `GetPart`'s `QueryRef` function |
|
787
|
|
|
788
|
```typescript |
|
789
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
790
|
import { connectorConfig, getPartRef, GetPartVariables } from '@dataconnect/generated'; |
|
791
|
|
|
792
|
// The `GetPart` query requires an argument of type `GetPartVariables`: |
|
793
|
const getPartVars: GetPartVariables = { |
|
794
|
id: ..., |
|
795
|
}; |
|
796
|
|
|
797
|
// Call the `getPartRef()` function to get a reference to the query. |
|
798
|
const ref = getPartRef(getPartVars); |
|
799
|
// Variables can be defined inline as well. |
|
800
|
const ref = getPartRef({ id: ..., }); |
|
801
|
|
|
802
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
803
|
const dataConnect = getDataConnect(connectorConfig); |
|
804
|
const ref = getPartRef(dataConnect, getPartVars); |
|
805
|
|
|
806
|
// Call `executeQuery()` on the reference to execute the query. |
|
807
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
808
|
const { data } = await executeQuery(ref); |
|
809
|
|
|
810
|
console.log(data.part); |
|
811
|
|
|
812
|
// Or, you can use the `Promise` API. |
|
813
|
executeQuery(ref).then((response) => { |
|
814
|
const data = response.data; |
|
815
|
console.log(data.part); |
|
816
|
}); |
|
817
|
``` |
|
818
|
|
|
819
|
## ListParts |
|
820
|
You can execute the `ListParts` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
821
|
```typescript |
|
822
|
listParts(options?: ExecuteQueryOptions): QueryPromise<ListPartsData, undefined>; |
|
823
|
|
|
824
|
interface ListPartsRef { |
|
825
|
... |
|
826
|
/* Allow users to create refs without passing in DataConnect */ |
|
827
|
(): QueryRef<ListPartsData, undefined>; |
|
828
|
} |
|
829
|
export const listPartsRef: ListPartsRef; |
|
830
|
``` |
|
831
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
832
|
```typescript |
|
833
|
listParts(dc: DataConnect, options?: ExecuteQueryOptions): QueryPromise<ListPartsData, undefined>; |
|
834
|
|
|
835
|
interface ListPartsRef { |
|
836
|
... |
|
837
|
(dc: DataConnect): QueryRef<ListPartsData, undefined>; |
|
838
|
} |
|
839
|
export const listPartsRef: ListPartsRef; |
|
840
|
``` |
|
841
|
|
|
842
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listPartsRef: |
|
843
|
```typescript |
|
844
|
const name = listPartsRef.operationName; |
|
845
|
console.log(name); |
|
846
|
``` |
|
847
|
|
|
848
|
### Variables |
|
849
|
The `ListParts` query has no variables. |
|
850
|
### Return Type |
|
851
|
Recall that executing the `ListParts` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
852
|
|
|
853
|
The `data` property is an object of type `ListPartsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
854
|
```typescript |
|
855
|
export interface ListPartsData { |
|
856
|
parts: ({ |
|
857
|
partName: string; |
|
858
|
})[]; |
|
859
|
} |
|
860
|
``` |
|
861
|
### Using `ListParts`'s action shortcut function |
|
862
|
|
|
863
|
```typescript |
|
864
|
import { getDataConnect } from 'firebase/data-connect'; |
|
865
|
import { connectorConfig, listParts } from '@dataconnect/generated'; |
|
866
|
|
|
867
|
|
|
868
|
// Call the `listParts()` function to execute the query. |
|
869
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
870
|
const { data } = await listParts(); |
|
871
|
|
|
872
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
873
|
const dataConnect = getDataConnect(connectorConfig); |
|
874
|
const { data } = await listParts(dataConnect); |
|
875
|
|
|
876
|
console.log(data.parts); |
|
877
|
|
|
878
|
// Or, you can use the `Promise` API. |
|
879
|
listParts().then((response) => { |
|
880
|
const data = response.data; |
|
881
|
console.log(data.parts); |
|
882
|
}); |
|
883
|
``` |
|
884
|
|
|
885
|
### Using `ListParts`'s `QueryRef` function |
|
886
|
|
|
887
|
```typescript |
|
888
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
889
|
import { connectorConfig, listPartsRef } from '@dataconnect/generated'; |
|
890
|
|
|
891
|
|
|
892
|
// Call the `listPartsRef()` function to get a reference to the query. |
|
893
|
const ref = listPartsRef(); |
|
894
|
|
|
895
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
896
|
const dataConnect = getDataConnect(connectorConfig); |
|
897
|
const ref = listPartsRef(dataConnect); |
|
898
|
|
|
899
|
// Call `executeQuery()` on the reference to execute the query. |
|
900
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
901
|
const { data } = await executeQuery(ref); |
|
902
|
|
|
903
|
console.log(data.parts); |
|
904
|
|
|
905
|
// Or, you can use the `Promise` API. |
|
906
|
executeQuery(ref).then((response) => { |
|
907
|
const data = response.data; |
|
908
|
console.log(data.parts); |
|
909
|
}); |
|
910
|
``` |
|
911
|
|
|
912
|
## GetStep |
|
913
|
You can execute the `GetStep` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
914
|
```typescript |
|
915
|
getStep(vars: GetStepVariables, options?: ExecuteQueryOptions): QueryPromise<GetStepData, GetStepVariables>; |
|
916
|
|
|
917
|
interface GetStepRef { |
|
918
|
... |
|
919
|
/* Allow users to create refs without passing in DataConnect */ |
|
920
|
(vars: GetStepVariables): QueryRef<GetStepData, GetStepVariables>; |
|
921
|
} |
|
922
|
export const getStepRef: GetStepRef; |
|
923
|
``` |
|
924
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
925
|
```typescript |
|
926
|
getStep(dc: DataConnect, vars: GetStepVariables, options?: ExecuteQueryOptions): QueryPromise<GetStepData, GetStepVariables>; |
|
927
|
|
|
928
|
interface GetStepRef { |
|
929
|
... |
|
930
|
(dc: DataConnect, vars: GetStepVariables): QueryRef<GetStepData, GetStepVariables>; |
|
931
|
} |
|
932
|
export const getStepRef: GetStepRef; |
|
933
|
``` |
|
934
|
|
|
935
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getStepRef: |
|
936
|
```typescript |
|
937
|
const name = getStepRef.operationName; |
|
938
|
console.log(name); |
|
939
|
``` |
|
940
|
|
|
941
|
### Variables |
|
942
|
The `GetStep` query requires an argument of type `GetStepVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
943
|
|
|
944
|
```typescript |
|
945
|
export interface GetStepVariables { |
|
946
|
id: UUIDString; |
|
947
|
} |
|
948
|
``` |
|
949
|
### Return Type |
|
950
|
Recall that executing the `GetStep` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
951
|
|
|
952
|
The `data` property is an object of type `GetStepData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
953
|
```typescript |
|
954
|
export interface GetStepData { |
|
955
|
step?: { |
|
956
|
instructionText: string; |
|
957
|
}; |
|
958
|
} |
|
959
|
``` |
|
960
|
### Using `GetStep`'s action shortcut function |
|
961
|
|
|
962
|
```typescript |
|
963
|
import { getDataConnect } from 'firebase/data-connect'; |
|
964
|
import { connectorConfig, getStep, GetStepVariables } from '@dataconnect/generated'; |
|
965
|
|
|
966
|
// The `GetStep` query requires an argument of type `GetStepVariables`: |
|
967
|
const getStepVars: GetStepVariables = { |
|
968
|
id: ..., |
|
969
|
}; |
|
970
|
|
|
971
|
// Call the `getStep()` function to execute the query. |
|
972
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
973
|
const { data } = await getStep(getStepVars); |
|
974
|
// Variables can be defined inline as well. |
|
975
|
const { data } = await getStep({ id: ..., }); |
|
976
|
|
|
977
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
978
|
const dataConnect = getDataConnect(connectorConfig); |
|
979
|
const { data } = await getStep(dataConnect, getStepVars); |
|
980
|
|
|
981
|
console.log(data.step); |
|
982
|
|
|
983
|
// Or, you can use the `Promise` API. |
|
984
|
getStep(getStepVars).then((response) => { |
|
985
|
const data = response.data; |
|
986
|
console.log(data.step); |
|
987
|
}); |
|
988
|
``` |
|
989
|
|
|
990
|
### Using `GetStep`'s `QueryRef` function |
|
991
|
|
|
992
|
```typescript |
|
993
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
994
|
import { connectorConfig, getStepRef, GetStepVariables } from '@dataconnect/generated'; |
|
995
|
|
|
996
|
// The `GetStep` query requires an argument of type `GetStepVariables`: |
|
997
|
const getStepVars: GetStepVariables = { |
|
998
|
id: ..., |
|
999
|
}; |
|
1000
|
|
|
1001
|
// Call the `getStepRef()` function to get a reference to the query. |
|
1002
|
const ref = getStepRef(getStepVars); |
|
1003
|
// Variables can be defined inline as well. |
|
1004
|
const ref = getStepRef({ id: ..., }); |
|
1005
|
|
|
1006
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
1007
|
const dataConnect = getDataConnect(connectorConfig); |
|
1008
|
const ref = getStepRef(dataConnect, getStepVars); |
|
1009
|
|
|
1010
|
// Call `executeQuery()` on the reference to execute the query. |
|
1011
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1012
|
const { data } = await executeQuery(ref); |
|
1013
|
|
|
1014
|
console.log(data.step); |
|
1015
|
|
|
1016
|
// Or, you can use the `Promise` API. |
|
1017
|
executeQuery(ref).then((response) => { |
|
1018
|
const data = response.data; |
|
1019
|
console.log(data.step); |
|
1020
|
}); |
|
1021
|
``` |
|
1022
|
|
|
1023
|
## ListSteps |
|
1024
|
You can execute the `ListSteps` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1025
|
```typescript |
|
1026
|
listSteps(options?: ExecuteQueryOptions): QueryPromise<ListStepsData, undefined>; |
|
1027
|
|
|
1028
|
interface ListStepsRef { |
|
1029
|
... |
|
1030
|
/* Allow users to create refs without passing in DataConnect */ |
|
1031
|
(): QueryRef<ListStepsData, undefined>; |
|
1032
|
} |
|
1033
|
export const listStepsRef: ListStepsRef; |
|
1034
|
``` |
|
1035
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
1036
|
```typescript |
|
1037
|
listSteps(dc: DataConnect, options?: ExecuteQueryOptions): QueryPromise<ListStepsData, undefined>; |
|
1038
|
|
|
1039
|
interface ListStepsRef { |
|
1040
|
... |
|
1041
|
(dc: DataConnect): QueryRef<ListStepsData, undefined>; |
|
1042
|
} |
|
1043
|
export const listStepsRef: ListStepsRef; |
|
1044
|
``` |
|
1045
|
|
|
1046
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listStepsRef: |
|
1047
|
```typescript |
|
1048
|
const name = listStepsRef.operationName; |
|
1049
|
console.log(name); |
|
1050
|
``` |
|
1051
|
|
|
1052
|
### Variables |
|
1053
|
The `ListSteps` query has no variables. |
|
1054
|
### Return Type |
|
1055
|
Recall that executing the `ListSteps` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
1056
|
|
|
1057
|
The `data` property is an object of type `ListStepsData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1058
|
```typescript |
|
1059
|
export interface ListStepsData { |
|
1060
|
steps: ({ |
|
1061
|
instructionText: string; |
|
1062
|
})[]; |
|
1063
|
} |
|
1064
|
``` |
|
1065
|
### Using `ListSteps`'s action shortcut function |
|
1066
|
|
|
1067
|
```typescript |
|
1068
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1069
|
import { connectorConfig, listSteps } from '@dataconnect/generated'; |
|
1070
|
|
|
1071
|
|
|
1072
|
// Call the `listSteps()` function to execute the query. |
|
1073
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1074
|
const { data } = await listSteps(); |
|
1075
|
|
|
1076
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1077
|
const dataConnect = getDataConnect(connectorConfig); |
|
1078
|
const { data } = await listSteps(dataConnect); |
|
1079
|
|
|
1080
|
console.log(data.steps); |
|
1081
|
|
|
1082
|
// Or, you can use the `Promise` API. |
|
1083
|
listSteps().then((response) => { |
|
1084
|
const data = response.data; |
|
1085
|
console.log(data.steps); |
|
1086
|
}); |
|
1087
|
``` |
|
1088
|
|
|
1089
|
### Using `ListSteps`'s `QueryRef` function |
|
1090
|
|
|
1091
|
```typescript |
|
1092
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
1093
|
import { connectorConfig, listStepsRef } from '@dataconnect/generated'; |
|
1094
|
|
|
1095
|
|
|
1096
|
// Call the `listStepsRef()` function to get a reference to the query. |
|
1097
|
const ref = listStepsRef(); |
|
1098
|
|
|
1099
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
1100
|
const dataConnect = getDataConnect(connectorConfig); |
|
1101
|
const ref = listStepsRef(dataConnect); |
|
1102
|
|
|
1103
|
// Call `executeQuery()` on the reference to execute the query. |
|
1104
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1105
|
const { data } = await executeQuery(ref); |
|
1106
|
|
|
1107
|
console.log(data.steps); |
|
1108
|
|
|
1109
|
// Or, you can use the `Promise` API. |
|
1110
|
executeQuery(ref).then((response) => { |
|
1111
|
const data = response.data; |
|
1112
|
console.log(data.steps); |
|
1113
|
}); |
|
1114
|
``` |
|
1115
|
|
|
1116
|
## GetMyBookmarks |
|
1117
|
You can execute the `GetMyBookmarks` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1118
|
```typescript |
|
1119
|
getMyBookmarks(options?: ExecuteQueryOptions): QueryPromise<GetMyBookmarksData, undefined>; |
|
1120
|
|
|
1121
|
interface GetMyBookmarksRef { |
|
1122
|
... |
|
1123
|
/* Allow users to create refs without passing in DataConnect */ |
|
1124
|
(): QueryRef<GetMyBookmarksData, undefined>; |
|
1125
|
} |
|
1126
|
export const getMyBookmarksRef: GetMyBookmarksRef; |
|
1127
|
``` |
|
1128
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
1129
|
```typescript |
|
1130
|
getMyBookmarks(dc: DataConnect, options?: ExecuteQueryOptions): QueryPromise<GetMyBookmarksData, undefined>; |
|
1131
|
|
|
1132
|
interface GetMyBookmarksRef { |
|
1133
|
... |
|
1134
|
(dc: DataConnect): QueryRef<GetMyBookmarksData, undefined>; |
|
1135
|
} |
|
1136
|
export const getMyBookmarksRef: GetMyBookmarksRef; |
|
1137
|
``` |
|
1138
|
|
|
1139
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getMyBookmarksRef: |
|
1140
|
```typescript |
|
1141
|
const name = getMyBookmarksRef.operationName; |
|
1142
|
console.log(name); |
|
1143
|
``` |
|
1144
|
|
|
1145
|
### Variables |
|
1146
|
The `GetMyBookmarks` query has no variables. |
|
1147
|
### Return Type |
|
1148
|
Recall that executing the `GetMyBookmarks` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
1149
|
|
|
1150
|
The `data` property is an object of type `GetMyBookmarksData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1151
|
```typescript |
|
1152
|
export interface GetMyBookmarksData { |
|
1153
|
userBookmarks: ({ |
|
1154
|
guide: { |
|
1155
|
title: string; |
|
1156
|
}; |
|
1157
|
})[]; |
|
1158
|
} |
|
1159
|
``` |
|
1160
|
### Using `GetMyBookmarks`'s action shortcut function |
|
1161
|
|
|
1162
|
```typescript |
|
1163
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1164
|
import { connectorConfig, getMyBookmarks } from '@dataconnect/generated'; |
|
1165
|
|
|
1166
|
|
|
1167
|
// Call the `getMyBookmarks()` function to execute the query. |
|
1168
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1169
|
const { data } = await getMyBookmarks(); |
|
1170
|
|
|
1171
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1172
|
const dataConnect = getDataConnect(connectorConfig); |
|
1173
|
const { data } = await getMyBookmarks(dataConnect); |
|
1174
|
|
|
1175
|
console.log(data.userBookmarks); |
|
1176
|
|
|
1177
|
// Or, you can use the `Promise` API. |
|
1178
|
getMyBookmarks().then((response) => { |
|
1179
|
const data = response.data; |
|
1180
|
console.log(data.userBookmarks); |
|
1181
|
}); |
|
1182
|
``` |
|
1183
|
|
|
1184
|
### Using `GetMyBookmarks`'s `QueryRef` function |
|
1185
|
|
|
1186
|
```typescript |
|
1187
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
1188
|
import { connectorConfig, getMyBookmarksRef } from '@dataconnect/generated'; |
|
1189
|
|
|
1190
|
|
|
1191
|
// Call the `getMyBookmarksRef()` function to get a reference to the query. |
|
1192
|
const ref = getMyBookmarksRef(); |
|
1193
|
|
|
1194
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
1195
|
const dataConnect = getDataConnect(connectorConfig); |
|
1196
|
const ref = getMyBookmarksRef(dataConnect); |
|
1197
|
|
|
1198
|
// Call `executeQuery()` on the reference to execute the query. |
|
1199
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1200
|
const { data } = await executeQuery(ref); |
|
1201
|
|
|
1202
|
console.log(data.userBookmarks); |
|
1203
|
|
|
1204
|
// Or, you can use the `Promise` API. |
|
1205
|
executeQuery(ref).then((response) => { |
|
1206
|
const data = response.data; |
|
1207
|
console.log(data.userBookmarks); |
|
1208
|
}); |
|
1209
|
``` |
|
1210
|
|
|
1211
|
## GetBookmark |
|
1212
|
You can execute the `GetBookmark` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1213
|
```typescript |
|
1214
|
getBookmark(vars: GetBookmarkVariables, options?: ExecuteQueryOptions): QueryPromise<GetBookmarkData, GetBookmarkVariables>; |
|
1215
|
|
|
1216
|
interface GetBookmarkRef { |
|
1217
|
... |
|
1218
|
/* Allow users to create refs without passing in DataConnect */ |
|
1219
|
(vars: GetBookmarkVariables): QueryRef<GetBookmarkData, GetBookmarkVariables>; |
|
1220
|
} |
|
1221
|
export const getBookmarkRef: GetBookmarkRef; |
|
1222
|
``` |
|
1223
|
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function. |
|
1224
|
```typescript |
|
1225
|
getBookmark(dc: DataConnect, vars: GetBookmarkVariables, options?: ExecuteQueryOptions): QueryPromise<GetBookmarkData, GetBookmarkVariables>; |
|
1226
|
|
|
1227
|
interface GetBookmarkRef { |
|
1228
|
... |
|
1229
|
(dc: DataConnect, vars: GetBookmarkVariables): QueryRef<GetBookmarkData, GetBookmarkVariables>; |
|
1230
|
} |
|
1231
|
export const getBookmarkRef: GetBookmarkRef; |
|
1232
|
``` |
|
1233
|
|
|
1234
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the getBookmarkRef: |
|
1235
|
```typescript |
|
1236
|
const name = getBookmarkRef.operationName; |
|
1237
|
console.log(name); |
|
1238
|
``` |
|
1239
|
|
|
1240
|
### Variables |
|
1241
|
The `GetBookmark` query requires an argument of type `GetBookmarkVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1242
|
|
|
1243
|
```typescript |
|
1244
|
export interface GetBookmarkVariables { |
|
1245
|
id: UUIDString; |
|
1246
|
} |
|
1247
|
``` |
|
1248
|
### Return Type |
|
1249
|
Recall that executing the `GetBookmark` query returns a `QueryPromise` that resolves to an object with a `data` property. |
|
1250
|
|
|
1251
|
The `data` property is an object of type `GetBookmarkData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1252
|
```typescript |
|
1253
|
export interface GetBookmarkData { |
|
1254
|
userBookmark?: { |
|
1255
|
userId: string; |
|
1256
|
}; |
|
1257
|
} |
|
1258
|
``` |
|
1259
|
### Using `GetBookmark`'s action shortcut function |
|
1260
|
|
|
1261
|
```typescript |
|
1262
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1263
|
import { connectorConfig, getBookmark, GetBookmarkVariables } from '@dataconnect/generated'; |
|
1264
|
|
|
1265
|
// The `GetBookmark` query requires an argument of type `GetBookmarkVariables`: |
|
1266
|
const getBookmarkVars: GetBookmarkVariables = { |
|
1267
|
id: ..., |
|
1268
|
}; |
|
1269
|
|
|
1270
|
// Call the `getBookmark()` function to execute the query. |
|
1271
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1272
|
const { data } = await getBookmark(getBookmarkVars); |
|
1273
|
// Variables can be defined inline as well. |
|
1274
|
const { data } = await getBookmark({ id: ..., }); |
|
1275
|
|
|
1276
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1277
|
const dataConnect = getDataConnect(connectorConfig); |
|
1278
|
const { data } = await getBookmark(dataConnect, getBookmarkVars); |
|
1279
|
|
|
1280
|
console.log(data.userBookmark); |
|
1281
|
|
|
1282
|
// Or, you can use the `Promise` API. |
|
1283
|
getBookmark(getBookmarkVars).then((response) => { |
|
1284
|
const data = response.data; |
|
1285
|
console.log(data.userBookmark); |
|
1286
|
}); |
|
1287
|
``` |
|
1288
|
|
|
1289
|
### Using `GetBookmark`'s `QueryRef` function |
|
1290
|
|
|
1291
|
```typescript |
|
1292
|
import { getDataConnect, executeQuery } from 'firebase/data-connect'; |
|
1293
|
import { connectorConfig, getBookmarkRef, GetBookmarkVariables } from '@dataconnect/generated'; |
|
1294
|
|
|
1295
|
// The `GetBookmark` query requires an argument of type `GetBookmarkVariables`: |
|
1296
|
const getBookmarkVars: GetBookmarkVariables = { |
|
1297
|
id: ..., |
|
1298
|
}; |
|
1299
|
|
|
1300
|
// Call the `getBookmarkRef()` function to get a reference to the query. |
|
1301
|
const ref = getBookmarkRef(getBookmarkVars); |
|
1302
|
// Variables can be defined inline as well. |
|
1303
|
const ref = getBookmarkRef({ id: ..., }); |
|
1304
|
|
|
1305
|
// You can also pass in a `DataConnect` instance to the `QueryRef` function. |
|
1306
|
const dataConnect = getDataConnect(connectorConfig); |
|
1307
|
const ref = getBookmarkRef(dataConnect, getBookmarkVars); |
|
1308
|
|
|
1309
|
// Call `executeQuery()` on the reference to execute the query. |
|
1310
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1311
|
const { data } = await executeQuery(ref); |
|
1312
|
|
|
1313
|
console.log(data.userBookmark); |
|
1314
|
|
|
1315
|
// Or, you can use the `Promise` API. |
|
1316
|
executeQuery(ref).then((response) => { |
|
1317
|
const data = response.data; |
|
1318
|
console.log(data.userBookmark); |
|
1319
|
}); |
|
1320
|
``` |
|
1321
|
|
|
1322
|
# Mutations |
|
1323
|
|
|
1324
|
There are two ways to execute a Data Connect Mutation using the generated Web SDK: |
|
1325
|
- Using a Mutation Reference function, which returns a `MutationRef` |
|
1326
|
- The `MutationRef` can be used as an argument to `executeMutation()`, which will execute the Mutation and return a `MutationPromise` |
|
1327
|
- Using an action shortcut function, which returns a `MutationPromise` |
|
1328
|
- Calling the action shortcut function will execute the Mutation and return a `MutationPromise` |
|
1329
|
|
|
1330
|
The following is true for both the action shortcut function and the `MutationRef` function: |
|
1331
|
- The `MutationPromise` returned will resolve to the result of the Mutation once it has finished executing |
|
1332
|
- If the Mutation accepts arguments, both the action shortcut function and the `MutationRef` function accept a single argument: an object that contains all the required variables (and the optional variables) for the Mutation |
|
1333
|
- Both functions can be called with or without passing in a `DataConnect` instance as an argument. If no `DataConnect` argument is passed in, then the generated SDK will call `getDataConnect(connectorConfig)` behind the scenes for you. |
|
1334
|
|
|
1335
|
Below are examples of how to use the `example` connector's generated functions to execute each mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#using-mutations). |
|
1336
|
|
|
1337
|
## CreateCategory |
|
1338
|
You can execute the `CreateCategory` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1339
|
```typescript |
|
1340
|
createCategory(): MutationPromise<CreateCategoryData, undefined>; |
|
1341
|
|
|
1342
|
interface CreateCategoryRef { |
|
1343
|
... |
|
1344
|
/* Allow users to create refs without passing in DataConnect */ |
|
1345
|
(): MutationRef<CreateCategoryData, undefined>; |
|
1346
|
} |
|
1347
|
export const createCategoryRef: CreateCategoryRef; |
|
1348
|
``` |
|
1349
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
1350
|
```typescript |
|
1351
|
createCategory(dc: DataConnect): MutationPromise<CreateCategoryData, undefined>; |
|
1352
|
|
|
1353
|
interface CreateCategoryRef { |
|
1354
|
... |
|
1355
|
(dc: DataConnect): MutationRef<CreateCategoryData, undefined>; |
|
1356
|
} |
|
1357
|
export const createCategoryRef: CreateCategoryRef; |
|
1358
|
``` |
|
1359
|
|
|
1360
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the createCategoryRef: |
|
1361
|
```typescript |
|
1362
|
const name = createCategoryRef.operationName; |
|
1363
|
console.log(name); |
|
1364
|
``` |
|
1365
|
|
|
1366
|
### Variables |
|
1367
|
The `CreateCategory` mutation has no variables. |
|
1368
|
### Return Type |
|
1369
|
Recall that executing the `CreateCategory` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
1370
|
|
|
1371
|
The `data` property is an object of type `CreateCategoryData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1372
|
```typescript |
|
1373
|
export interface CreateCategoryData { |
|
1374
|
category_insert: Category_Key; |
|
1375
|
} |
|
1376
|
``` |
|
1377
|
### Using `CreateCategory`'s action shortcut function |
|
1378
|
|
|
1379
|
```typescript |
|
1380
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1381
|
import { connectorConfig, createCategory } from '@dataconnect/generated'; |
|
1382
|
|
|
1383
|
|
|
1384
|
// Call the `createCategory()` function to execute the mutation. |
|
1385
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1386
|
const { data } = await createCategory(); |
|
1387
|
|
|
1388
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1389
|
const dataConnect = getDataConnect(connectorConfig); |
|
1390
|
const { data } = await createCategory(dataConnect); |
|
1391
|
|
|
1392
|
console.log(data.category_insert); |
|
1393
|
|
|
1394
|
// Or, you can use the `Promise` API. |
|
1395
|
createCategory().then((response) => { |
|
1396
|
const data = response.data; |
|
1397
|
console.log(data.category_insert); |
|
1398
|
}); |
|
1399
|
``` |
|
1400
|
|
|
1401
|
### Using `CreateCategory`'s `MutationRef` function |
|
1402
|
|
|
1403
|
```typescript |
|
1404
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
1405
|
import { connectorConfig, createCategoryRef } from '@dataconnect/generated'; |
|
1406
|
|
|
1407
|
|
|
1408
|
// Call the `createCategoryRef()` function to get a reference to the mutation. |
|
1409
|
const ref = createCategoryRef(); |
|
1410
|
|
|
1411
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
1412
|
const dataConnect = getDataConnect(connectorConfig); |
|
1413
|
const ref = createCategoryRef(dataConnect); |
|
1414
|
|
|
1415
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
1416
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1417
|
const { data } = await executeMutation(ref); |
|
1418
|
|
|
1419
|
console.log(data.category_insert); |
|
1420
|
|
|
1421
|
// Or, you can use the `Promise` API. |
|
1422
|
executeMutation(ref).then((response) => { |
|
1423
|
const data = response.data; |
|
1424
|
console.log(data.category_insert); |
|
1425
|
}); |
|
1426
|
``` |
|
1427
|
|
|
1428
|
## UpsertCategory |
|
1429
|
You can execute the `UpsertCategory` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1430
|
```typescript |
|
1431
|
upsertCategory(vars: UpsertCategoryVariables): MutationPromise<UpsertCategoryData, UpsertCategoryVariables>; |
|
1432
|
|
|
1433
|
interface UpsertCategoryRef { |
|
1434
|
... |
|
1435
|
/* Allow users to create refs without passing in DataConnect */ |
|
1436
|
(vars: UpsertCategoryVariables): MutationRef<UpsertCategoryData, UpsertCategoryVariables>; |
|
1437
|
} |
|
1438
|
export const upsertCategoryRef: UpsertCategoryRef; |
|
1439
|
``` |
|
1440
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
1441
|
```typescript |
|
1442
|
upsertCategory(dc: DataConnect, vars: UpsertCategoryVariables): MutationPromise<UpsertCategoryData, UpsertCategoryVariables>; |
|
1443
|
|
|
1444
|
interface UpsertCategoryRef { |
|
1445
|
... |
|
1446
|
(dc: DataConnect, vars: UpsertCategoryVariables): MutationRef<UpsertCategoryData, UpsertCategoryVariables>; |
|
1447
|
} |
|
1448
|
export const upsertCategoryRef: UpsertCategoryRef; |
|
1449
|
``` |
|
1450
|
|
|
1451
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the upsertCategoryRef: |
|
1452
|
```typescript |
|
1453
|
const name = upsertCategoryRef.operationName; |
|
1454
|
console.log(name); |
|
1455
|
``` |
|
1456
|
|
|
1457
|
### Variables |
|
1458
|
The `UpsertCategory` mutation requires an argument of type `UpsertCategoryVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1459
|
|
|
1460
|
```typescript |
|
1461
|
export interface UpsertCategoryVariables { |
|
1462
|
id: UUIDString; |
|
1463
|
} |
|
1464
|
``` |
|
1465
|
### Return Type |
|
1466
|
Recall that executing the `UpsertCategory` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
1467
|
|
|
1468
|
The `data` property is an object of type `UpsertCategoryData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1469
|
```typescript |
|
1470
|
export interface UpsertCategoryData { |
|
1471
|
category_upsert: Category_Key; |
|
1472
|
} |
|
1473
|
``` |
|
1474
|
### Using `UpsertCategory`'s action shortcut function |
|
1475
|
|
|
1476
|
```typescript |
|
1477
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1478
|
import { connectorConfig, upsertCategory, UpsertCategoryVariables } from '@dataconnect/generated'; |
|
1479
|
|
|
1480
|
// The `UpsertCategory` mutation requires an argument of type `UpsertCategoryVariables`: |
|
1481
|
const upsertCategoryVars: UpsertCategoryVariables = { |
|
1482
|
id: ..., |
|
1483
|
}; |
|
1484
|
|
|
1485
|
// Call the `upsertCategory()` function to execute the mutation. |
|
1486
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1487
|
const { data } = await upsertCategory(upsertCategoryVars); |
|
1488
|
// Variables can be defined inline as well. |
|
1489
|
const { data } = await upsertCategory({ id: ..., }); |
|
1490
|
|
|
1491
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1492
|
const dataConnect = getDataConnect(connectorConfig); |
|
1493
|
const { data } = await upsertCategory(dataConnect, upsertCategoryVars); |
|
1494
|
|
|
1495
|
console.log(data.category_upsert); |
|
1496
|
|
|
1497
|
// Or, you can use the `Promise` API. |
|
1498
|
upsertCategory(upsertCategoryVars).then((response) => { |
|
1499
|
const data = response.data; |
|
1500
|
console.log(data.category_upsert); |
|
1501
|
}); |
|
1502
|
``` |
|
1503
|
|
|
1504
|
### Using `UpsertCategory`'s `MutationRef` function |
|
1505
|
|
|
1506
|
```typescript |
|
1507
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
1508
|
import { connectorConfig, upsertCategoryRef, UpsertCategoryVariables } from '@dataconnect/generated'; |
|
1509
|
|
|
1510
|
// The `UpsertCategory` mutation requires an argument of type `UpsertCategoryVariables`: |
|
1511
|
const upsertCategoryVars: UpsertCategoryVariables = { |
|
1512
|
id: ..., |
|
1513
|
}; |
|
1514
|
|
|
1515
|
// Call the `upsertCategoryRef()` function to get a reference to the mutation. |
|
1516
|
const ref = upsertCategoryRef(upsertCategoryVars); |
|
1517
|
// Variables can be defined inline as well. |
|
1518
|
const ref = upsertCategoryRef({ id: ..., }); |
|
1519
|
|
|
1520
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
1521
|
const dataConnect = getDataConnect(connectorConfig); |
|
1522
|
const ref = upsertCategoryRef(dataConnect, upsertCategoryVars); |
|
1523
|
|
|
1524
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
1525
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1526
|
const { data } = await executeMutation(ref); |
|
1527
|
|
|
1528
|
console.log(data.category_upsert); |
|
1529
|
|
|
1530
|
// Or, you can use the `Promise` API. |
|
1531
|
executeMutation(ref).then((response) => { |
|
1532
|
const data = response.data; |
|
1533
|
console.log(data.category_upsert); |
|
1534
|
}); |
|
1535
|
``` |
|
1536
|
|
|
1537
|
## DeleteCategory |
|
1538
|
You can execute the `DeleteCategory` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1539
|
```typescript |
|
1540
|
deleteCategory(vars: DeleteCategoryVariables): MutationPromise<DeleteCategoryData, DeleteCategoryVariables>; |
|
1541
|
|
|
1542
|
interface DeleteCategoryRef { |
|
1543
|
... |
|
1544
|
/* Allow users to create refs without passing in DataConnect */ |
|
1545
|
(vars: DeleteCategoryVariables): MutationRef<DeleteCategoryData, DeleteCategoryVariables>; |
|
1546
|
} |
|
1547
|
export const deleteCategoryRef: DeleteCategoryRef; |
|
1548
|
``` |
|
1549
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
1550
|
```typescript |
|
1551
|
deleteCategory(dc: DataConnect, vars: DeleteCategoryVariables): MutationPromise<DeleteCategoryData, DeleteCategoryVariables>; |
|
1552
|
|
|
1553
|
interface DeleteCategoryRef { |
|
1554
|
... |
|
1555
|
(dc: DataConnect, vars: DeleteCategoryVariables): MutationRef<DeleteCategoryData, DeleteCategoryVariables>; |
|
1556
|
} |
|
1557
|
export const deleteCategoryRef: DeleteCategoryRef; |
|
1558
|
``` |
|
1559
|
|
|
1560
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deleteCategoryRef: |
|
1561
|
```typescript |
|
1562
|
const name = deleteCategoryRef.operationName; |
|
1563
|
console.log(name); |
|
1564
|
``` |
|
1565
|
|
|
1566
|
### Variables |
|
1567
|
The `DeleteCategory` mutation requires an argument of type `DeleteCategoryVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1568
|
|
|
1569
|
```typescript |
|
1570
|
export interface DeleteCategoryVariables { |
|
1571
|
id: UUIDString; |
|
1572
|
} |
|
1573
|
``` |
|
1574
|
### Return Type |
|
1575
|
Recall that executing the `DeleteCategory` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
1576
|
|
|
1577
|
The `data` property is an object of type `DeleteCategoryData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1578
|
```typescript |
|
1579
|
export interface DeleteCategoryData { |
|
1580
|
category_delete?: Category_Key | null; |
|
1581
|
} |
|
1582
|
``` |
|
1583
|
### Using `DeleteCategory`'s action shortcut function |
|
1584
|
|
|
1585
|
```typescript |
|
1586
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1587
|
import { connectorConfig, deleteCategory, DeleteCategoryVariables } from '@dataconnect/generated'; |
|
1588
|
|
|
1589
|
// The `DeleteCategory` mutation requires an argument of type `DeleteCategoryVariables`: |
|
1590
|
const deleteCategoryVars: DeleteCategoryVariables = { |
|
1591
|
id: ..., |
|
1592
|
}; |
|
1593
|
|
|
1594
|
// Call the `deleteCategory()` function to execute the mutation. |
|
1595
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1596
|
const { data } = await deleteCategory(deleteCategoryVars); |
|
1597
|
// Variables can be defined inline as well. |
|
1598
|
const { data } = await deleteCategory({ id: ..., }); |
|
1599
|
|
|
1600
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1601
|
const dataConnect = getDataConnect(connectorConfig); |
|
1602
|
const { data } = await deleteCategory(dataConnect, deleteCategoryVars); |
|
1603
|
|
|
1604
|
console.log(data.category_delete); |
|
1605
|
|
|
1606
|
// Or, you can use the `Promise` API. |
|
1607
|
deleteCategory(deleteCategoryVars).then((response) => { |
|
1608
|
const data = response.data; |
|
1609
|
console.log(data.category_delete); |
|
1610
|
}); |
|
1611
|
``` |
|
1612
|
|
|
1613
|
### Using `DeleteCategory`'s `MutationRef` function |
|
1614
|
|
|
1615
|
```typescript |
|
1616
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
1617
|
import { connectorConfig, deleteCategoryRef, DeleteCategoryVariables } from '@dataconnect/generated'; |
|
1618
|
|
|
1619
|
// The `DeleteCategory` mutation requires an argument of type `DeleteCategoryVariables`: |
|
1620
|
const deleteCategoryVars: DeleteCategoryVariables = { |
|
1621
|
id: ..., |
|
1622
|
}; |
|
1623
|
|
|
1624
|
// Call the `deleteCategoryRef()` function to get a reference to the mutation. |
|
1625
|
const ref = deleteCategoryRef(deleteCategoryVars); |
|
1626
|
// Variables can be defined inline as well. |
|
1627
|
const ref = deleteCategoryRef({ id: ..., }); |
|
1628
|
|
|
1629
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
1630
|
const dataConnect = getDataConnect(connectorConfig); |
|
1631
|
const ref = deleteCategoryRef(dataConnect, deleteCategoryVars); |
|
1632
|
|
|
1633
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
1634
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1635
|
const { data } = await executeMutation(ref); |
|
1636
|
|
|
1637
|
console.log(data.category_delete); |
|
1638
|
|
|
1639
|
// Or, you can use the `Promise` API. |
|
1640
|
executeMutation(ref).then((response) => { |
|
1641
|
const data = response.data; |
|
1642
|
console.log(data.category_delete); |
|
1643
|
}); |
|
1644
|
``` |
|
1645
|
|
|
1646
|
## UpdateCategory |
|
1647
|
You can execute the `UpdateCategory` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1648
|
```typescript |
|
1649
|
updateCategory(vars: UpdateCategoryVariables): MutationPromise<UpdateCategoryData, UpdateCategoryVariables>; |
|
1650
|
|
|
1651
|
interface UpdateCategoryRef { |
|
1652
|
... |
|
1653
|
/* Allow users to create refs without passing in DataConnect */ |
|
1654
|
(vars: UpdateCategoryVariables): MutationRef<UpdateCategoryData, UpdateCategoryVariables>; |
|
1655
|
} |
|
1656
|
export const updateCategoryRef: UpdateCategoryRef; |
|
1657
|
``` |
|
1658
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
1659
|
```typescript |
|
1660
|
updateCategory(dc: DataConnect, vars: UpdateCategoryVariables): MutationPromise<UpdateCategoryData, UpdateCategoryVariables>; |
|
1661
|
|
|
1662
|
interface UpdateCategoryRef { |
|
1663
|
... |
|
1664
|
(dc: DataConnect, vars: UpdateCategoryVariables): MutationRef<UpdateCategoryData, UpdateCategoryVariables>; |
|
1665
|
} |
|
1666
|
export const updateCategoryRef: UpdateCategoryRef; |
|
1667
|
``` |
|
1668
|
|
|
1669
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updateCategoryRef: |
|
1670
|
```typescript |
|
1671
|
const name = updateCategoryRef.operationName; |
|
1672
|
console.log(name); |
|
1673
|
``` |
|
1674
|
|
|
1675
|
### Variables |
|
1676
|
The `UpdateCategory` mutation requires an argument of type `UpdateCategoryVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1677
|
|
|
1678
|
```typescript |
|
1679
|
export interface UpdateCategoryVariables { |
|
1680
|
id: UUIDString; |
|
1681
|
name: string; |
|
1682
|
} |
|
1683
|
``` |
|
1684
|
### Return Type |
|
1685
|
Recall that executing the `UpdateCategory` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
1686
|
|
|
1687
|
The `data` property is an object of type `UpdateCategoryData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1688
|
```typescript |
|
1689
|
export interface UpdateCategoryData { |
|
1690
|
category_update?: Category_Key | null; |
|
1691
|
} |
|
1692
|
``` |
|
1693
|
### Using `UpdateCategory`'s action shortcut function |
|
1694
|
|
|
1695
|
```typescript |
|
1696
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1697
|
import { connectorConfig, updateCategory, UpdateCategoryVariables } from '@dataconnect/generated'; |
|
1698
|
|
|
1699
|
// The `UpdateCategory` mutation requires an argument of type `UpdateCategoryVariables`: |
|
1700
|
const updateCategoryVars: UpdateCategoryVariables = { |
|
1701
|
id: ..., |
|
1702
|
name: ..., |
|
1703
|
}; |
|
1704
|
|
|
1705
|
// Call the `updateCategory()` function to execute the mutation. |
|
1706
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1707
|
const { data } = await updateCategory(updateCategoryVars); |
|
1708
|
// Variables can be defined inline as well. |
|
1709
|
const { data } = await updateCategory({ id: ..., name: ..., }); |
|
1710
|
|
|
1711
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1712
|
const dataConnect = getDataConnect(connectorConfig); |
|
1713
|
const { data } = await updateCategory(dataConnect, updateCategoryVars); |
|
1714
|
|
|
1715
|
console.log(data.category_update); |
|
1716
|
|
|
1717
|
// Or, you can use the `Promise` API. |
|
1718
|
updateCategory(updateCategoryVars).then((response) => { |
|
1719
|
const data = response.data; |
|
1720
|
console.log(data.category_update); |
|
1721
|
}); |
|
1722
|
``` |
|
1723
|
|
|
1724
|
### Using `UpdateCategory`'s `MutationRef` function |
|
1725
|
|
|
1726
|
```typescript |
|
1727
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
1728
|
import { connectorConfig, updateCategoryRef, UpdateCategoryVariables } from '@dataconnect/generated'; |
|
1729
|
|
|
1730
|
// The `UpdateCategory` mutation requires an argument of type `UpdateCategoryVariables`: |
|
1731
|
const updateCategoryVars: UpdateCategoryVariables = { |
|
1732
|
id: ..., |
|
1733
|
name: ..., |
|
1734
|
}; |
|
1735
|
|
|
1736
|
// Call the `updateCategoryRef()` function to get a reference to the mutation. |
|
1737
|
const ref = updateCategoryRef(updateCategoryVars); |
|
1738
|
// Variables can be defined inline as well. |
|
1739
|
const ref = updateCategoryRef({ id: ..., name: ..., }); |
|
1740
|
|
|
1741
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
1742
|
const dataConnect = getDataConnect(connectorConfig); |
|
1743
|
const ref = updateCategoryRef(dataConnect, updateCategoryVars); |
|
1744
|
|
|
1745
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
1746
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1747
|
const { data } = await executeMutation(ref); |
|
1748
|
|
|
1749
|
console.log(data.category_update); |
|
1750
|
|
|
1751
|
// Or, you can use the `Promise` API. |
|
1752
|
executeMutation(ref).then((response) => { |
|
1753
|
const data = response.data; |
|
1754
|
console.log(data.category_update); |
|
1755
|
}); |
|
1756
|
``` |
|
1757
|
|
|
1758
|
## CreateDevice |
|
1759
|
You can execute the `CreateDevice` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1760
|
```typescript |
|
1761
|
createDevice(): MutationPromise<CreateDeviceData, undefined>; |
|
1762
|
|
|
1763
|
interface CreateDeviceRef { |
|
1764
|
... |
|
1765
|
/* Allow users to create refs without passing in DataConnect */ |
|
1766
|
(): MutationRef<CreateDeviceData, undefined>; |
|
1767
|
} |
|
1768
|
export const createDeviceRef: CreateDeviceRef; |
|
1769
|
``` |
|
1770
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
1771
|
```typescript |
|
1772
|
createDevice(dc: DataConnect): MutationPromise<CreateDeviceData, undefined>; |
|
1773
|
|
|
1774
|
interface CreateDeviceRef { |
|
1775
|
... |
|
1776
|
(dc: DataConnect): MutationRef<CreateDeviceData, undefined>; |
|
1777
|
} |
|
1778
|
export const createDeviceRef: CreateDeviceRef; |
|
1779
|
``` |
|
1780
|
|
|
1781
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the createDeviceRef: |
|
1782
|
```typescript |
|
1783
|
const name = createDeviceRef.operationName; |
|
1784
|
console.log(name); |
|
1785
|
``` |
|
1786
|
|
|
1787
|
### Variables |
|
1788
|
The `CreateDevice` mutation has no variables. |
|
1789
|
### Return Type |
|
1790
|
Recall that executing the `CreateDevice` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
1791
|
|
|
1792
|
The `data` property is an object of type `CreateDeviceData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1793
|
```typescript |
|
1794
|
export interface CreateDeviceData { |
|
1795
|
device_insert: Device_Key; |
|
1796
|
} |
|
1797
|
``` |
|
1798
|
### Using `CreateDevice`'s action shortcut function |
|
1799
|
|
|
1800
|
```typescript |
|
1801
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1802
|
import { connectorConfig, createDevice } from '@dataconnect/generated'; |
|
1803
|
|
|
1804
|
|
|
1805
|
// Call the `createDevice()` function to execute the mutation. |
|
1806
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1807
|
const { data } = await createDevice(); |
|
1808
|
|
|
1809
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1810
|
const dataConnect = getDataConnect(connectorConfig); |
|
1811
|
const { data } = await createDevice(dataConnect); |
|
1812
|
|
|
1813
|
console.log(data.device_insert); |
|
1814
|
|
|
1815
|
// Or, you can use the `Promise` API. |
|
1816
|
createDevice().then((response) => { |
|
1817
|
const data = response.data; |
|
1818
|
console.log(data.device_insert); |
|
1819
|
}); |
|
1820
|
``` |
|
1821
|
|
|
1822
|
### Using `CreateDevice`'s `MutationRef` function |
|
1823
|
|
|
1824
|
```typescript |
|
1825
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
1826
|
import { connectorConfig, createDeviceRef } from '@dataconnect/generated'; |
|
1827
|
|
|
1828
|
|
|
1829
|
// Call the `createDeviceRef()` function to get a reference to the mutation. |
|
1830
|
const ref = createDeviceRef(); |
|
1831
|
|
|
1832
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
1833
|
const dataConnect = getDataConnect(connectorConfig); |
|
1834
|
const ref = createDeviceRef(dataConnect); |
|
1835
|
|
|
1836
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
1837
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1838
|
const { data } = await executeMutation(ref); |
|
1839
|
|
|
1840
|
console.log(data.device_insert); |
|
1841
|
|
|
1842
|
// Or, you can use the `Promise` API. |
|
1843
|
executeMutation(ref).then((response) => { |
|
1844
|
const data = response.data; |
|
1845
|
console.log(data.device_insert); |
|
1846
|
}); |
|
1847
|
``` |
|
1848
|
|
|
1849
|
## UpsertDevice |
|
1850
|
You can execute the `UpsertDevice` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1851
|
```typescript |
|
1852
|
upsertDevice(vars: UpsertDeviceVariables): MutationPromise<UpsertDeviceData, UpsertDeviceVariables>; |
|
1853
|
|
|
1854
|
interface UpsertDeviceRef { |
|
1855
|
... |
|
1856
|
/* Allow users to create refs without passing in DataConnect */ |
|
1857
|
(vars: UpsertDeviceVariables): MutationRef<UpsertDeviceData, UpsertDeviceVariables>; |
|
1858
|
} |
|
1859
|
export const upsertDeviceRef: UpsertDeviceRef; |
|
1860
|
``` |
|
1861
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
1862
|
```typescript |
|
1863
|
upsertDevice(dc: DataConnect, vars: UpsertDeviceVariables): MutationPromise<UpsertDeviceData, UpsertDeviceVariables>; |
|
1864
|
|
|
1865
|
interface UpsertDeviceRef { |
|
1866
|
... |
|
1867
|
(dc: DataConnect, vars: UpsertDeviceVariables): MutationRef<UpsertDeviceData, UpsertDeviceVariables>; |
|
1868
|
} |
|
1869
|
export const upsertDeviceRef: UpsertDeviceRef; |
|
1870
|
``` |
|
1871
|
|
|
1872
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the upsertDeviceRef: |
|
1873
|
```typescript |
|
1874
|
const name = upsertDeviceRef.operationName; |
|
1875
|
console.log(name); |
|
1876
|
``` |
|
1877
|
|
|
1878
|
### Variables |
|
1879
|
The `UpsertDevice` mutation requires an argument of type `UpsertDeviceVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1880
|
|
|
1881
|
```typescript |
|
1882
|
export interface UpsertDeviceVariables { |
|
1883
|
id: UUIDString; |
|
1884
|
} |
|
1885
|
``` |
|
1886
|
### Return Type |
|
1887
|
Recall that executing the `UpsertDevice` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
1888
|
|
|
1889
|
The `data` property is an object of type `UpsertDeviceData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1890
|
```typescript |
|
1891
|
export interface UpsertDeviceData { |
|
1892
|
device_upsert: Device_Key; |
|
1893
|
} |
|
1894
|
``` |
|
1895
|
### Using `UpsertDevice`'s action shortcut function |
|
1896
|
|
|
1897
|
```typescript |
|
1898
|
import { getDataConnect } from 'firebase/data-connect'; |
|
1899
|
import { connectorConfig, upsertDevice, UpsertDeviceVariables } from '@dataconnect/generated'; |
|
1900
|
|
|
1901
|
// The `UpsertDevice` mutation requires an argument of type `UpsertDeviceVariables`: |
|
1902
|
const upsertDeviceVars: UpsertDeviceVariables = { |
|
1903
|
id: ..., |
|
1904
|
}; |
|
1905
|
|
|
1906
|
// Call the `upsertDevice()` function to execute the mutation. |
|
1907
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1908
|
const { data } = await upsertDevice(upsertDeviceVars); |
|
1909
|
// Variables can be defined inline as well. |
|
1910
|
const { data } = await upsertDevice({ id: ..., }); |
|
1911
|
|
|
1912
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
1913
|
const dataConnect = getDataConnect(connectorConfig); |
|
1914
|
const { data } = await upsertDevice(dataConnect, upsertDeviceVars); |
|
1915
|
|
|
1916
|
console.log(data.device_upsert); |
|
1917
|
|
|
1918
|
// Or, you can use the `Promise` API. |
|
1919
|
upsertDevice(upsertDeviceVars).then((response) => { |
|
1920
|
const data = response.data; |
|
1921
|
console.log(data.device_upsert); |
|
1922
|
}); |
|
1923
|
``` |
|
1924
|
|
|
1925
|
### Using `UpsertDevice`'s `MutationRef` function |
|
1926
|
|
|
1927
|
```typescript |
|
1928
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
1929
|
import { connectorConfig, upsertDeviceRef, UpsertDeviceVariables } from '@dataconnect/generated'; |
|
1930
|
|
|
1931
|
// The `UpsertDevice` mutation requires an argument of type `UpsertDeviceVariables`: |
|
1932
|
const upsertDeviceVars: UpsertDeviceVariables = { |
|
1933
|
id: ..., |
|
1934
|
}; |
|
1935
|
|
|
1936
|
// Call the `upsertDeviceRef()` function to get a reference to the mutation. |
|
1937
|
const ref = upsertDeviceRef(upsertDeviceVars); |
|
1938
|
// Variables can be defined inline as well. |
|
1939
|
const ref = upsertDeviceRef({ id: ..., }); |
|
1940
|
|
|
1941
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
1942
|
const dataConnect = getDataConnect(connectorConfig); |
|
1943
|
const ref = upsertDeviceRef(dataConnect, upsertDeviceVars); |
|
1944
|
|
|
1945
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
1946
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
1947
|
const { data } = await executeMutation(ref); |
|
1948
|
|
|
1949
|
console.log(data.device_upsert); |
|
1950
|
|
|
1951
|
// Or, you can use the `Promise` API. |
|
1952
|
executeMutation(ref).then((response) => { |
|
1953
|
const data = response.data; |
|
1954
|
console.log(data.device_upsert); |
|
1955
|
}); |
|
1956
|
``` |
|
1957
|
|
|
1958
|
## DeleteDevice |
|
1959
|
You can execute the `DeleteDevice` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
1960
|
```typescript |
|
1961
|
deleteDevice(vars: DeleteDeviceVariables): MutationPromise<DeleteDeviceData, DeleteDeviceVariables>; |
|
1962
|
|
|
1963
|
interface DeleteDeviceRef { |
|
1964
|
... |
|
1965
|
/* Allow users to create refs without passing in DataConnect */ |
|
1966
|
(vars: DeleteDeviceVariables): MutationRef<DeleteDeviceData, DeleteDeviceVariables>; |
|
1967
|
} |
|
1968
|
export const deleteDeviceRef: DeleteDeviceRef; |
|
1969
|
``` |
|
1970
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
1971
|
```typescript |
|
1972
|
deleteDevice(dc: DataConnect, vars: DeleteDeviceVariables): MutationPromise<DeleteDeviceData, DeleteDeviceVariables>; |
|
1973
|
|
|
1974
|
interface DeleteDeviceRef { |
|
1975
|
... |
|
1976
|
(dc: DataConnect, vars: DeleteDeviceVariables): MutationRef<DeleteDeviceData, DeleteDeviceVariables>; |
|
1977
|
} |
|
1978
|
export const deleteDeviceRef: DeleteDeviceRef; |
|
1979
|
``` |
|
1980
|
|
|
1981
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deleteDeviceRef: |
|
1982
|
```typescript |
|
1983
|
const name = deleteDeviceRef.operationName; |
|
1984
|
console.log(name); |
|
1985
|
``` |
|
1986
|
|
|
1987
|
### Variables |
|
1988
|
The `DeleteDevice` mutation requires an argument of type `DeleteDeviceVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1989
|
|
|
1990
|
```typescript |
|
1991
|
export interface DeleteDeviceVariables { |
|
1992
|
id: UUIDString; |
|
1993
|
} |
|
1994
|
``` |
|
1995
|
### Return Type |
|
1996
|
Recall that executing the `DeleteDevice` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
1997
|
|
|
1998
|
The `data` property is an object of type `DeleteDeviceData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
1999
|
```typescript |
|
2000
|
export interface DeleteDeviceData { |
|
2001
|
device_delete?: Device_Key | null; |
|
2002
|
} |
|
2003
|
``` |
|
2004
|
### Using `DeleteDevice`'s action shortcut function |
|
2005
|
|
|
2006
|
```typescript |
|
2007
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2008
|
import { connectorConfig, deleteDevice, DeleteDeviceVariables } from '@dataconnect/generated'; |
|
2009
|
|
|
2010
|
// The `DeleteDevice` mutation requires an argument of type `DeleteDeviceVariables`: |
|
2011
|
const deleteDeviceVars: DeleteDeviceVariables = { |
|
2012
|
id: ..., |
|
2013
|
}; |
|
2014
|
|
|
2015
|
// Call the `deleteDevice()` function to execute the mutation. |
|
2016
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2017
|
const { data } = await deleteDevice(deleteDeviceVars); |
|
2018
|
// Variables can be defined inline as well. |
|
2019
|
const { data } = await deleteDevice({ id: ..., }); |
|
2020
|
|
|
2021
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2022
|
const dataConnect = getDataConnect(connectorConfig); |
|
2023
|
const { data } = await deleteDevice(dataConnect, deleteDeviceVars); |
|
2024
|
|
|
2025
|
console.log(data.device_delete); |
|
2026
|
|
|
2027
|
// Or, you can use the `Promise` API. |
|
2028
|
deleteDevice(deleteDeviceVars).then((response) => { |
|
2029
|
const data = response.data; |
|
2030
|
console.log(data.device_delete); |
|
2031
|
}); |
|
2032
|
``` |
|
2033
|
|
|
2034
|
### Using `DeleteDevice`'s `MutationRef` function |
|
2035
|
|
|
2036
|
```typescript |
|
2037
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2038
|
import { connectorConfig, deleteDeviceRef, DeleteDeviceVariables } from '@dataconnect/generated'; |
|
2039
|
|
|
2040
|
// The `DeleteDevice` mutation requires an argument of type `DeleteDeviceVariables`: |
|
2041
|
const deleteDeviceVars: DeleteDeviceVariables = { |
|
2042
|
id: ..., |
|
2043
|
}; |
|
2044
|
|
|
2045
|
// Call the `deleteDeviceRef()` function to get a reference to the mutation. |
|
2046
|
const ref = deleteDeviceRef(deleteDeviceVars); |
|
2047
|
// Variables can be defined inline as well. |
|
2048
|
const ref = deleteDeviceRef({ id: ..., }); |
|
2049
|
|
|
2050
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2051
|
const dataConnect = getDataConnect(connectorConfig); |
|
2052
|
const ref = deleteDeviceRef(dataConnect, deleteDeviceVars); |
|
2053
|
|
|
2054
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2055
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2056
|
const { data } = await executeMutation(ref); |
|
2057
|
|
|
2058
|
console.log(data.device_delete); |
|
2059
|
|
|
2060
|
// Or, you can use the `Promise` API. |
|
2061
|
executeMutation(ref).then((response) => { |
|
2062
|
const data = response.data; |
|
2063
|
console.log(data.device_delete); |
|
2064
|
}); |
|
2065
|
``` |
|
2066
|
|
|
2067
|
## UpdateDevice |
|
2068
|
You can execute the `UpdateDevice` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2069
|
```typescript |
|
2070
|
updateDevice(vars: UpdateDeviceVariables): MutationPromise<UpdateDeviceData, UpdateDeviceVariables>; |
|
2071
|
|
|
2072
|
interface UpdateDeviceRef { |
|
2073
|
... |
|
2074
|
/* Allow users to create refs without passing in DataConnect */ |
|
2075
|
(vars: UpdateDeviceVariables): MutationRef<UpdateDeviceData, UpdateDeviceVariables>; |
|
2076
|
} |
|
2077
|
export const updateDeviceRef: UpdateDeviceRef; |
|
2078
|
``` |
|
2079
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2080
|
```typescript |
|
2081
|
updateDevice(dc: DataConnect, vars: UpdateDeviceVariables): MutationPromise<UpdateDeviceData, UpdateDeviceVariables>; |
|
2082
|
|
|
2083
|
interface UpdateDeviceRef { |
|
2084
|
... |
|
2085
|
(dc: DataConnect, vars: UpdateDeviceVariables): MutationRef<UpdateDeviceData, UpdateDeviceVariables>; |
|
2086
|
} |
|
2087
|
export const updateDeviceRef: UpdateDeviceRef; |
|
2088
|
``` |
|
2089
|
|
|
2090
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updateDeviceRef: |
|
2091
|
```typescript |
|
2092
|
const name = updateDeviceRef.operationName; |
|
2093
|
console.log(name); |
|
2094
|
``` |
|
2095
|
|
|
2096
|
### Variables |
|
2097
|
The `UpdateDevice` mutation requires an argument of type `UpdateDeviceVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2098
|
|
|
2099
|
```typescript |
|
2100
|
export interface UpdateDeviceVariables { |
|
2101
|
id: UUIDString; |
|
2102
|
modelName: string; |
|
2103
|
} |
|
2104
|
``` |
|
2105
|
### Return Type |
|
2106
|
Recall that executing the `UpdateDevice` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2107
|
|
|
2108
|
The `data` property is an object of type `UpdateDeviceData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2109
|
```typescript |
|
2110
|
export interface UpdateDeviceData { |
|
2111
|
device_update?: Device_Key | null; |
|
2112
|
} |
|
2113
|
``` |
|
2114
|
### Using `UpdateDevice`'s action shortcut function |
|
2115
|
|
|
2116
|
```typescript |
|
2117
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2118
|
import { connectorConfig, updateDevice, UpdateDeviceVariables } from '@dataconnect/generated'; |
|
2119
|
|
|
2120
|
// The `UpdateDevice` mutation requires an argument of type `UpdateDeviceVariables`: |
|
2121
|
const updateDeviceVars: UpdateDeviceVariables = { |
|
2122
|
id: ..., |
|
2123
|
modelName: ..., |
|
2124
|
}; |
|
2125
|
|
|
2126
|
// Call the `updateDevice()` function to execute the mutation. |
|
2127
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2128
|
const { data } = await updateDevice(updateDeviceVars); |
|
2129
|
// Variables can be defined inline as well. |
|
2130
|
const { data } = await updateDevice({ id: ..., modelName: ..., }); |
|
2131
|
|
|
2132
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2133
|
const dataConnect = getDataConnect(connectorConfig); |
|
2134
|
const { data } = await updateDevice(dataConnect, updateDeviceVars); |
|
2135
|
|
|
2136
|
console.log(data.device_update); |
|
2137
|
|
|
2138
|
// Or, you can use the `Promise` API. |
|
2139
|
updateDevice(updateDeviceVars).then((response) => { |
|
2140
|
const data = response.data; |
|
2141
|
console.log(data.device_update); |
|
2142
|
}); |
|
2143
|
``` |
|
2144
|
|
|
2145
|
### Using `UpdateDevice`'s `MutationRef` function |
|
2146
|
|
|
2147
|
```typescript |
|
2148
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2149
|
import { connectorConfig, updateDeviceRef, UpdateDeviceVariables } from '@dataconnect/generated'; |
|
2150
|
|
|
2151
|
// The `UpdateDevice` mutation requires an argument of type `UpdateDeviceVariables`: |
|
2152
|
const updateDeviceVars: UpdateDeviceVariables = { |
|
2153
|
id: ..., |
|
2154
|
modelName: ..., |
|
2155
|
}; |
|
2156
|
|
|
2157
|
// Call the `updateDeviceRef()` function to get a reference to the mutation. |
|
2158
|
const ref = updateDeviceRef(updateDeviceVars); |
|
2159
|
// Variables can be defined inline as well. |
|
2160
|
const ref = updateDeviceRef({ id: ..., modelName: ..., }); |
|
2161
|
|
|
2162
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2163
|
const dataConnect = getDataConnect(connectorConfig); |
|
2164
|
const ref = updateDeviceRef(dataConnect, updateDeviceVars); |
|
2165
|
|
|
2166
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2167
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2168
|
const { data } = await executeMutation(ref); |
|
2169
|
|
|
2170
|
console.log(data.device_update); |
|
2171
|
|
|
2172
|
// Or, you can use the `Promise` API. |
|
2173
|
executeMutation(ref).then((response) => { |
|
2174
|
const data = response.data; |
|
2175
|
console.log(data.device_update); |
|
2176
|
}); |
|
2177
|
``` |
|
2178
|
|
|
2179
|
## CreateGuide |
|
2180
|
You can execute the `CreateGuide` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2181
|
```typescript |
|
2182
|
createGuide(vars: CreateGuideVariables): MutationPromise<CreateGuideData, CreateGuideVariables>; |
|
2183
|
|
|
2184
|
interface CreateGuideRef { |
|
2185
|
... |
|
2186
|
/* Allow users to create refs without passing in DataConnect */ |
|
2187
|
(vars: CreateGuideVariables): MutationRef<CreateGuideData, CreateGuideVariables>; |
|
2188
|
} |
|
2189
|
export const createGuideRef: CreateGuideRef; |
|
2190
|
``` |
|
2191
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2192
|
```typescript |
|
2193
|
createGuide(dc: DataConnect, vars: CreateGuideVariables): MutationPromise<CreateGuideData, CreateGuideVariables>; |
|
2194
|
|
|
2195
|
interface CreateGuideRef { |
|
2196
|
... |
|
2197
|
(dc: DataConnect, vars: CreateGuideVariables): MutationRef<CreateGuideData, CreateGuideVariables>; |
|
2198
|
} |
|
2199
|
export const createGuideRef: CreateGuideRef; |
|
2200
|
``` |
|
2201
|
|
|
2202
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the createGuideRef: |
|
2203
|
```typescript |
|
2204
|
const name = createGuideRef.operationName; |
|
2205
|
console.log(name); |
|
2206
|
``` |
|
2207
|
|
|
2208
|
### Variables |
|
2209
|
The `CreateGuide` mutation requires an argument of type `CreateGuideVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2210
|
|
|
2211
|
```typescript |
|
2212
|
export interface CreateGuideVariables { |
|
2213
|
title: string; |
|
2214
|
difficulty: string; |
|
2215
|
time: number; |
|
2216
|
} |
|
2217
|
``` |
|
2218
|
### Return Type |
|
2219
|
Recall that executing the `CreateGuide` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2220
|
|
|
2221
|
The `data` property is an object of type `CreateGuideData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2222
|
```typescript |
|
2223
|
export interface CreateGuideData { |
|
2224
|
guide_insert: Guide_Key; |
|
2225
|
} |
|
2226
|
``` |
|
2227
|
### Using `CreateGuide`'s action shortcut function |
|
2228
|
|
|
2229
|
```typescript |
|
2230
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2231
|
import { connectorConfig, createGuide, CreateGuideVariables } from '@dataconnect/generated'; |
|
2232
|
|
|
2233
|
// The `CreateGuide` mutation requires an argument of type `CreateGuideVariables`: |
|
2234
|
const createGuideVars: CreateGuideVariables = { |
|
2235
|
title: ..., |
|
2236
|
difficulty: ..., |
|
2237
|
time: ..., |
|
2238
|
}; |
|
2239
|
|
|
2240
|
// Call the `createGuide()` function to execute the mutation. |
|
2241
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2242
|
const { data } = await createGuide(createGuideVars); |
|
2243
|
// Variables can be defined inline as well. |
|
2244
|
const { data } = await createGuide({ title: ..., difficulty: ..., time: ..., }); |
|
2245
|
|
|
2246
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2247
|
const dataConnect = getDataConnect(connectorConfig); |
|
2248
|
const { data } = await createGuide(dataConnect, createGuideVars); |
|
2249
|
|
|
2250
|
console.log(data.guide_insert); |
|
2251
|
|
|
2252
|
// Or, you can use the `Promise` API. |
|
2253
|
createGuide(createGuideVars).then((response) => { |
|
2254
|
const data = response.data; |
|
2255
|
console.log(data.guide_insert); |
|
2256
|
}); |
|
2257
|
``` |
|
2258
|
|
|
2259
|
### Using `CreateGuide`'s `MutationRef` function |
|
2260
|
|
|
2261
|
```typescript |
|
2262
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2263
|
import { connectorConfig, createGuideRef, CreateGuideVariables } from '@dataconnect/generated'; |
|
2264
|
|
|
2265
|
// The `CreateGuide` mutation requires an argument of type `CreateGuideVariables`: |
|
2266
|
const createGuideVars: CreateGuideVariables = { |
|
2267
|
title: ..., |
|
2268
|
difficulty: ..., |
|
2269
|
time: ..., |
|
2270
|
}; |
|
2271
|
|
|
2272
|
// Call the `createGuideRef()` function to get a reference to the mutation. |
|
2273
|
const ref = createGuideRef(createGuideVars); |
|
2274
|
// Variables can be defined inline as well. |
|
2275
|
const ref = createGuideRef({ title: ..., difficulty: ..., time: ..., }); |
|
2276
|
|
|
2277
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2278
|
const dataConnect = getDataConnect(connectorConfig); |
|
2279
|
const ref = createGuideRef(dataConnect, createGuideVars); |
|
2280
|
|
|
2281
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2282
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2283
|
const { data } = await executeMutation(ref); |
|
2284
|
|
|
2285
|
console.log(data.guide_insert); |
|
2286
|
|
|
2287
|
// Or, you can use the `Promise` API. |
|
2288
|
executeMutation(ref).then((response) => { |
|
2289
|
const data = response.data; |
|
2290
|
console.log(data.guide_insert); |
|
2291
|
}); |
|
2292
|
``` |
|
2293
|
|
|
2294
|
## UpsertGuide |
|
2295
|
You can execute the `UpsertGuide` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2296
|
```typescript |
|
2297
|
upsertGuide(vars: UpsertGuideVariables): MutationPromise<UpsertGuideData, UpsertGuideVariables>; |
|
2298
|
|
|
2299
|
interface UpsertGuideRef { |
|
2300
|
... |
|
2301
|
/* Allow users to create refs without passing in DataConnect */ |
|
2302
|
(vars: UpsertGuideVariables): MutationRef<UpsertGuideData, UpsertGuideVariables>; |
|
2303
|
} |
|
2304
|
export const upsertGuideRef: UpsertGuideRef; |
|
2305
|
``` |
|
2306
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2307
|
```typescript |
|
2308
|
upsertGuide(dc: DataConnect, vars: UpsertGuideVariables): MutationPromise<UpsertGuideData, UpsertGuideVariables>; |
|
2309
|
|
|
2310
|
interface UpsertGuideRef { |
|
2311
|
... |
|
2312
|
(dc: DataConnect, vars: UpsertGuideVariables): MutationRef<UpsertGuideData, UpsertGuideVariables>; |
|
2313
|
} |
|
2314
|
export const upsertGuideRef: UpsertGuideRef; |
|
2315
|
``` |
|
2316
|
|
|
2317
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the upsertGuideRef: |
|
2318
|
```typescript |
|
2319
|
const name = upsertGuideRef.operationName; |
|
2320
|
console.log(name); |
|
2321
|
``` |
|
2322
|
|
|
2323
|
### Variables |
|
2324
|
The `UpsertGuide` mutation requires an argument of type `UpsertGuideVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2325
|
|
|
2326
|
```typescript |
|
2327
|
export interface UpsertGuideVariables { |
|
2328
|
id: UUIDString; |
|
2329
|
title: string; |
|
2330
|
difficulty: string; |
|
2331
|
time: number; |
|
2332
|
} |
|
2333
|
``` |
|
2334
|
### Return Type |
|
2335
|
Recall that executing the `UpsertGuide` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2336
|
|
|
2337
|
The `data` property is an object of type `UpsertGuideData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2338
|
```typescript |
|
2339
|
export interface UpsertGuideData { |
|
2340
|
guide_upsert: Guide_Key; |
|
2341
|
} |
|
2342
|
``` |
|
2343
|
### Using `UpsertGuide`'s action shortcut function |
|
2344
|
|
|
2345
|
```typescript |
|
2346
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2347
|
import { connectorConfig, upsertGuide, UpsertGuideVariables } from '@dataconnect/generated'; |
|
2348
|
|
|
2349
|
// The `UpsertGuide` mutation requires an argument of type `UpsertGuideVariables`: |
|
2350
|
const upsertGuideVars: UpsertGuideVariables = { |
|
2351
|
id: ..., |
|
2352
|
title: ..., |
|
2353
|
difficulty: ..., |
|
2354
|
time: ..., |
|
2355
|
}; |
|
2356
|
|
|
2357
|
// Call the `upsertGuide()` function to execute the mutation. |
|
2358
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2359
|
const { data } = await upsertGuide(upsertGuideVars); |
|
2360
|
// Variables can be defined inline as well. |
|
2361
|
const { data } = await upsertGuide({ id: ..., title: ..., difficulty: ..., time: ..., }); |
|
2362
|
|
|
2363
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2364
|
const dataConnect = getDataConnect(connectorConfig); |
|
2365
|
const { data } = await upsertGuide(dataConnect, upsertGuideVars); |
|
2366
|
|
|
2367
|
console.log(data.guide_upsert); |
|
2368
|
|
|
2369
|
// Or, you can use the `Promise` API. |
|
2370
|
upsertGuide(upsertGuideVars).then((response) => { |
|
2371
|
const data = response.data; |
|
2372
|
console.log(data.guide_upsert); |
|
2373
|
}); |
|
2374
|
``` |
|
2375
|
|
|
2376
|
### Using `UpsertGuide`'s `MutationRef` function |
|
2377
|
|
|
2378
|
```typescript |
|
2379
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2380
|
import { connectorConfig, upsertGuideRef, UpsertGuideVariables } from '@dataconnect/generated'; |
|
2381
|
|
|
2382
|
// The `UpsertGuide` mutation requires an argument of type `UpsertGuideVariables`: |
|
2383
|
const upsertGuideVars: UpsertGuideVariables = { |
|
2384
|
id: ..., |
|
2385
|
title: ..., |
|
2386
|
difficulty: ..., |
|
2387
|
time: ..., |
|
2388
|
}; |
|
2389
|
|
|
2390
|
// Call the `upsertGuideRef()` function to get a reference to the mutation. |
|
2391
|
const ref = upsertGuideRef(upsertGuideVars); |
|
2392
|
// Variables can be defined inline as well. |
|
2393
|
const ref = upsertGuideRef({ id: ..., title: ..., difficulty: ..., time: ..., }); |
|
2394
|
|
|
2395
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2396
|
const dataConnect = getDataConnect(connectorConfig); |
|
2397
|
const ref = upsertGuideRef(dataConnect, upsertGuideVars); |
|
2398
|
|
|
2399
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2400
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2401
|
const { data } = await executeMutation(ref); |
|
2402
|
|
|
2403
|
console.log(data.guide_upsert); |
|
2404
|
|
|
2405
|
// Or, you can use the `Promise` API. |
|
2406
|
executeMutation(ref).then((response) => { |
|
2407
|
const data = response.data; |
|
2408
|
console.log(data.guide_upsert); |
|
2409
|
}); |
|
2410
|
``` |
|
2411
|
|
|
2412
|
## DeleteGuide |
|
2413
|
You can execute the `DeleteGuide` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2414
|
```typescript |
|
2415
|
deleteGuide(vars: DeleteGuideVariables): MutationPromise<DeleteGuideData, DeleteGuideVariables>; |
|
2416
|
|
|
2417
|
interface DeleteGuideRef { |
|
2418
|
... |
|
2419
|
/* Allow users to create refs without passing in DataConnect */ |
|
2420
|
(vars: DeleteGuideVariables): MutationRef<DeleteGuideData, DeleteGuideVariables>; |
|
2421
|
} |
|
2422
|
export const deleteGuideRef: DeleteGuideRef; |
|
2423
|
``` |
|
2424
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2425
|
```typescript |
|
2426
|
deleteGuide(dc: DataConnect, vars: DeleteGuideVariables): MutationPromise<DeleteGuideData, DeleteGuideVariables>; |
|
2427
|
|
|
2428
|
interface DeleteGuideRef { |
|
2429
|
... |
|
2430
|
(dc: DataConnect, vars: DeleteGuideVariables): MutationRef<DeleteGuideData, DeleteGuideVariables>; |
|
2431
|
} |
|
2432
|
export const deleteGuideRef: DeleteGuideRef; |
|
2433
|
``` |
|
2434
|
|
|
2435
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deleteGuideRef: |
|
2436
|
```typescript |
|
2437
|
const name = deleteGuideRef.operationName; |
|
2438
|
console.log(name); |
|
2439
|
``` |
|
2440
|
|
|
2441
|
### Variables |
|
2442
|
The `DeleteGuide` mutation requires an argument of type `DeleteGuideVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2443
|
|
|
2444
|
```typescript |
|
2445
|
export interface DeleteGuideVariables { |
|
2446
|
id: UUIDString; |
|
2447
|
} |
|
2448
|
``` |
|
2449
|
### Return Type |
|
2450
|
Recall that executing the `DeleteGuide` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2451
|
|
|
2452
|
The `data` property is an object of type `DeleteGuideData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2453
|
```typescript |
|
2454
|
export interface DeleteGuideData { |
|
2455
|
guide_delete?: Guide_Key | null; |
|
2456
|
} |
|
2457
|
``` |
|
2458
|
### Using `DeleteGuide`'s action shortcut function |
|
2459
|
|
|
2460
|
```typescript |
|
2461
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2462
|
import { connectorConfig, deleteGuide, DeleteGuideVariables } from '@dataconnect/generated'; |
|
2463
|
|
|
2464
|
// The `DeleteGuide` mutation requires an argument of type `DeleteGuideVariables`: |
|
2465
|
const deleteGuideVars: DeleteGuideVariables = { |
|
2466
|
id: ..., |
|
2467
|
}; |
|
2468
|
|
|
2469
|
// Call the `deleteGuide()` function to execute the mutation. |
|
2470
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2471
|
const { data } = await deleteGuide(deleteGuideVars); |
|
2472
|
// Variables can be defined inline as well. |
|
2473
|
const { data } = await deleteGuide({ id: ..., }); |
|
2474
|
|
|
2475
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2476
|
const dataConnect = getDataConnect(connectorConfig); |
|
2477
|
const { data } = await deleteGuide(dataConnect, deleteGuideVars); |
|
2478
|
|
|
2479
|
console.log(data.guide_delete); |
|
2480
|
|
|
2481
|
// Or, you can use the `Promise` API. |
|
2482
|
deleteGuide(deleteGuideVars).then((response) => { |
|
2483
|
const data = response.data; |
|
2484
|
console.log(data.guide_delete); |
|
2485
|
}); |
|
2486
|
``` |
|
2487
|
|
|
2488
|
### Using `DeleteGuide`'s `MutationRef` function |
|
2489
|
|
|
2490
|
```typescript |
|
2491
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2492
|
import { connectorConfig, deleteGuideRef, DeleteGuideVariables } from '@dataconnect/generated'; |
|
2493
|
|
|
2494
|
// The `DeleteGuide` mutation requires an argument of type `DeleteGuideVariables`: |
|
2495
|
const deleteGuideVars: DeleteGuideVariables = { |
|
2496
|
id: ..., |
|
2497
|
}; |
|
2498
|
|
|
2499
|
// Call the `deleteGuideRef()` function to get a reference to the mutation. |
|
2500
|
const ref = deleteGuideRef(deleteGuideVars); |
|
2501
|
// Variables can be defined inline as well. |
|
2502
|
const ref = deleteGuideRef({ id: ..., }); |
|
2503
|
|
|
2504
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2505
|
const dataConnect = getDataConnect(connectorConfig); |
|
2506
|
const ref = deleteGuideRef(dataConnect, deleteGuideVars); |
|
2507
|
|
|
2508
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2509
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2510
|
const { data } = await executeMutation(ref); |
|
2511
|
|
|
2512
|
console.log(data.guide_delete); |
|
2513
|
|
|
2514
|
// Or, you can use the `Promise` API. |
|
2515
|
executeMutation(ref).then((response) => { |
|
2516
|
const data = response.data; |
|
2517
|
console.log(data.guide_delete); |
|
2518
|
}); |
|
2519
|
``` |
|
2520
|
|
|
2521
|
## UpdateGuide |
|
2522
|
You can execute the `UpdateGuide` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2523
|
```typescript |
|
2524
|
updateGuide(vars: UpdateGuideVariables): MutationPromise<UpdateGuideData, UpdateGuideVariables>; |
|
2525
|
|
|
2526
|
interface UpdateGuideRef { |
|
2527
|
... |
|
2528
|
/* Allow users to create refs without passing in DataConnect */ |
|
2529
|
(vars: UpdateGuideVariables): MutationRef<UpdateGuideData, UpdateGuideVariables>; |
|
2530
|
} |
|
2531
|
export const updateGuideRef: UpdateGuideRef; |
|
2532
|
``` |
|
2533
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2534
|
```typescript |
|
2535
|
updateGuide(dc: DataConnect, vars: UpdateGuideVariables): MutationPromise<UpdateGuideData, UpdateGuideVariables>; |
|
2536
|
|
|
2537
|
interface UpdateGuideRef { |
|
2538
|
... |
|
2539
|
(dc: DataConnect, vars: UpdateGuideVariables): MutationRef<UpdateGuideData, UpdateGuideVariables>; |
|
2540
|
} |
|
2541
|
export const updateGuideRef: UpdateGuideRef; |
|
2542
|
``` |
|
2543
|
|
|
2544
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updateGuideRef: |
|
2545
|
```typescript |
|
2546
|
const name = updateGuideRef.operationName; |
|
2547
|
console.log(name); |
|
2548
|
``` |
|
2549
|
|
|
2550
|
### Variables |
|
2551
|
The `UpdateGuide` mutation requires an argument of type `UpdateGuideVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2552
|
|
|
2553
|
```typescript |
|
2554
|
export interface UpdateGuideVariables { |
|
2555
|
id: UUIDString; |
|
2556
|
time: number; |
|
2557
|
} |
|
2558
|
``` |
|
2559
|
### Return Type |
|
2560
|
Recall that executing the `UpdateGuide` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2561
|
|
|
2562
|
The `data` property is an object of type `UpdateGuideData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2563
|
```typescript |
|
2564
|
export interface UpdateGuideData { |
|
2565
|
guide_update?: Guide_Key | null; |
|
2566
|
} |
|
2567
|
``` |
|
2568
|
### Using `UpdateGuide`'s action shortcut function |
|
2569
|
|
|
2570
|
```typescript |
|
2571
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2572
|
import { connectorConfig, updateGuide, UpdateGuideVariables } from '@dataconnect/generated'; |
|
2573
|
|
|
2574
|
// The `UpdateGuide` mutation requires an argument of type `UpdateGuideVariables`: |
|
2575
|
const updateGuideVars: UpdateGuideVariables = { |
|
2576
|
id: ..., |
|
2577
|
time: ..., |
|
2578
|
}; |
|
2579
|
|
|
2580
|
// Call the `updateGuide()` function to execute the mutation. |
|
2581
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2582
|
const { data } = await updateGuide(updateGuideVars); |
|
2583
|
// Variables can be defined inline as well. |
|
2584
|
const { data } = await updateGuide({ id: ..., time: ..., }); |
|
2585
|
|
|
2586
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2587
|
const dataConnect = getDataConnect(connectorConfig); |
|
2588
|
const { data } = await updateGuide(dataConnect, updateGuideVars); |
|
2589
|
|
|
2590
|
console.log(data.guide_update); |
|
2591
|
|
|
2592
|
// Or, you can use the `Promise` API. |
|
2593
|
updateGuide(updateGuideVars).then((response) => { |
|
2594
|
const data = response.data; |
|
2595
|
console.log(data.guide_update); |
|
2596
|
}); |
|
2597
|
``` |
|
2598
|
|
|
2599
|
### Using `UpdateGuide`'s `MutationRef` function |
|
2600
|
|
|
2601
|
```typescript |
|
2602
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2603
|
import { connectorConfig, updateGuideRef, UpdateGuideVariables } from '@dataconnect/generated'; |
|
2604
|
|
|
2605
|
// The `UpdateGuide` mutation requires an argument of type `UpdateGuideVariables`: |
|
2606
|
const updateGuideVars: UpdateGuideVariables = { |
|
2607
|
id: ..., |
|
2608
|
time: ..., |
|
2609
|
}; |
|
2610
|
|
|
2611
|
// Call the `updateGuideRef()` function to get a reference to the mutation. |
|
2612
|
const ref = updateGuideRef(updateGuideVars); |
|
2613
|
// Variables can be defined inline as well. |
|
2614
|
const ref = updateGuideRef({ id: ..., time: ..., }); |
|
2615
|
|
|
2616
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2617
|
const dataConnect = getDataConnect(connectorConfig); |
|
2618
|
const ref = updateGuideRef(dataConnect, updateGuideVars); |
|
2619
|
|
|
2620
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2621
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2622
|
const { data } = await executeMutation(ref); |
|
2623
|
|
|
2624
|
console.log(data.guide_update); |
|
2625
|
|
|
2626
|
// Or, you can use the `Promise` API. |
|
2627
|
executeMutation(ref).then((response) => { |
|
2628
|
const data = response.data; |
|
2629
|
console.log(data.guide_update); |
|
2630
|
}); |
|
2631
|
``` |
|
2632
|
|
|
2633
|
## CreatePart |
|
2634
|
You can execute the `CreatePart` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2635
|
```typescript |
|
2636
|
createPart(vars: CreatePartVariables): MutationPromise<CreatePartData, CreatePartVariables>; |
|
2637
|
|
|
2638
|
interface CreatePartRef { |
|
2639
|
... |
|
2640
|
/* Allow users to create refs without passing in DataConnect */ |
|
2641
|
(vars: CreatePartVariables): MutationRef<CreatePartData, CreatePartVariables>; |
|
2642
|
} |
|
2643
|
export const createPartRef: CreatePartRef; |
|
2644
|
``` |
|
2645
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2646
|
```typescript |
|
2647
|
createPart(dc: DataConnect, vars: CreatePartVariables): MutationPromise<CreatePartData, CreatePartVariables>; |
|
2648
|
|
|
2649
|
interface CreatePartRef { |
|
2650
|
... |
|
2651
|
(dc: DataConnect, vars: CreatePartVariables): MutationRef<CreatePartData, CreatePartVariables>; |
|
2652
|
} |
|
2653
|
export const createPartRef: CreatePartRef; |
|
2654
|
``` |
|
2655
|
|
|
2656
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the createPartRef: |
|
2657
|
```typescript |
|
2658
|
const name = createPartRef.operationName; |
|
2659
|
console.log(name); |
|
2660
|
``` |
|
2661
|
|
|
2662
|
### Variables |
|
2663
|
The `CreatePart` mutation requires an argument of type `CreatePartVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2664
|
|
|
2665
|
```typescript |
|
2666
|
export interface CreatePartVariables { |
|
2667
|
name: string; |
|
2668
|
type: string; |
|
2669
|
devId: UUIDString; |
|
2670
|
} |
|
2671
|
``` |
|
2672
|
### Return Type |
|
2673
|
Recall that executing the `CreatePart` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2674
|
|
|
2675
|
The `data` property is an object of type `CreatePartData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2676
|
```typescript |
|
2677
|
export interface CreatePartData { |
|
2678
|
part_insert: Part_Key; |
|
2679
|
} |
|
2680
|
``` |
|
2681
|
### Using `CreatePart`'s action shortcut function |
|
2682
|
|
|
2683
|
```typescript |
|
2684
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2685
|
import { connectorConfig, createPart, CreatePartVariables } from '@dataconnect/generated'; |
|
2686
|
|
|
2687
|
// The `CreatePart` mutation requires an argument of type `CreatePartVariables`: |
|
2688
|
const createPartVars: CreatePartVariables = { |
|
2689
|
name: ..., |
|
2690
|
type: ..., |
|
2691
|
devId: ..., |
|
2692
|
}; |
|
2693
|
|
|
2694
|
// Call the `createPart()` function to execute the mutation. |
|
2695
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2696
|
const { data } = await createPart(createPartVars); |
|
2697
|
// Variables can be defined inline as well. |
|
2698
|
const { data } = await createPart({ name: ..., type: ..., devId: ..., }); |
|
2699
|
|
|
2700
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2701
|
const dataConnect = getDataConnect(connectorConfig); |
|
2702
|
const { data } = await createPart(dataConnect, createPartVars); |
|
2703
|
|
|
2704
|
console.log(data.part_insert); |
|
2705
|
|
|
2706
|
// Or, you can use the `Promise` API. |
|
2707
|
createPart(createPartVars).then((response) => { |
|
2708
|
const data = response.data; |
|
2709
|
console.log(data.part_insert); |
|
2710
|
}); |
|
2711
|
``` |
|
2712
|
|
|
2713
|
### Using `CreatePart`'s `MutationRef` function |
|
2714
|
|
|
2715
|
```typescript |
|
2716
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2717
|
import { connectorConfig, createPartRef, CreatePartVariables } from '@dataconnect/generated'; |
|
2718
|
|
|
2719
|
// The `CreatePart` mutation requires an argument of type `CreatePartVariables`: |
|
2720
|
const createPartVars: CreatePartVariables = { |
|
2721
|
name: ..., |
|
2722
|
type: ..., |
|
2723
|
devId: ..., |
|
2724
|
}; |
|
2725
|
|
|
2726
|
// Call the `createPartRef()` function to get a reference to the mutation. |
|
2727
|
const ref = createPartRef(createPartVars); |
|
2728
|
// Variables can be defined inline as well. |
|
2729
|
const ref = createPartRef({ name: ..., type: ..., devId: ..., }); |
|
2730
|
|
|
2731
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2732
|
const dataConnect = getDataConnect(connectorConfig); |
|
2733
|
const ref = createPartRef(dataConnect, createPartVars); |
|
2734
|
|
|
2735
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2736
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2737
|
const { data } = await executeMutation(ref); |
|
2738
|
|
|
2739
|
console.log(data.part_insert); |
|
2740
|
|
|
2741
|
// Or, you can use the `Promise` API. |
|
2742
|
executeMutation(ref).then((response) => { |
|
2743
|
const data = response.data; |
|
2744
|
console.log(data.part_insert); |
|
2745
|
}); |
|
2746
|
``` |
|
2747
|
|
|
2748
|
## UpsertPart |
|
2749
|
You can execute the `UpsertPart` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2750
|
```typescript |
|
2751
|
upsertPart(vars: UpsertPartVariables): MutationPromise<UpsertPartData, UpsertPartVariables>; |
|
2752
|
|
|
2753
|
interface UpsertPartRef { |
|
2754
|
... |
|
2755
|
/* Allow users to create refs without passing in DataConnect */ |
|
2756
|
(vars: UpsertPartVariables): MutationRef<UpsertPartData, UpsertPartVariables>; |
|
2757
|
} |
|
2758
|
export const upsertPartRef: UpsertPartRef; |
|
2759
|
``` |
|
2760
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2761
|
```typescript |
|
2762
|
upsertPart(dc: DataConnect, vars: UpsertPartVariables): MutationPromise<UpsertPartData, UpsertPartVariables>; |
|
2763
|
|
|
2764
|
interface UpsertPartRef { |
|
2765
|
... |
|
2766
|
(dc: DataConnect, vars: UpsertPartVariables): MutationRef<UpsertPartData, UpsertPartVariables>; |
|
2767
|
} |
|
2768
|
export const upsertPartRef: UpsertPartRef; |
|
2769
|
``` |
|
2770
|
|
|
2771
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the upsertPartRef: |
|
2772
|
```typescript |
|
2773
|
const name = upsertPartRef.operationName; |
|
2774
|
console.log(name); |
|
2775
|
``` |
|
2776
|
|
|
2777
|
### Variables |
|
2778
|
The `UpsertPart` mutation requires an argument of type `UpsertPartVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2779
|
|
|
2780
|
```typescript |
|
2781
|
export interface UpsertPartVariables { |
|
2782
|
id: UUIDString; |
|
2783
|
name: string; |
|
2784
|
type: string; |
|
2785
|
devId: UUIDString; |
|
2786
|
} |
|
2787
|
``` |
|
2788
|
### Return Type |
|
2789
|
Recall that executing the `UpsertPart` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2790
|
|
|
2791
|
The `data` property is an object of type `UpsertPartData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2792
|
```typescript |
|
2793
|
export interface UpsertPartData { |
|
2794
|
part_upsert: Part_Key; |
|
2795
|
} |
|
2796
|
``` |
|
2797
|
### Using `UpsertPart`'s action shortcut function |
|
2798
|
|
|
2799
|
```typescript |
|
2800
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2801
|
import { connectorConfig, upsertPart, UpsertPartVariables } from '@dataconnect/generated'; |
|
2802
|
|
|
2803
|
// The `UpsertPart` mutation requires an argument of type `UpsertPartVariables`: |
|
2804
|
const upsertPartVars: UpsertPartVariables = { |
|
2805
|
id: ..., |
|
2806
|
name: ..., |
|
2807
|
type: ..., |
|
2808
|
devId: ..., |
|
2809
|
}; |
|
2810
|
|
|
2811
|
// Call the `upsertPart()` function to execute the mutation. |
|
2812
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2813
|
const { data } = await upsertPart(upsertPartVars); |
|
2814
|
// Variables can be defined inline as well. |
|
2815
|
const { data } = await upsertPart({ id: ..., name: ..., type: ..., devId: ..., }); |
|
2816
|
|
|
2817
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2818
|
const dataConnect = getDataConnect(connectorConfig); |
|
2819
|
const { data } = await upsertPart(dataConnect, upsertPartVars); |
|
2820
|
|
|
2821
|
console.log(data.part_upsert); |
|
2822
|
|
|
2823
|
// Or, you can use the `Promise` API. |
|
2824
|
upsertPart(upsertPartVars).then((response) => { |
|
2825
|
const data = response.data; |
|
2826
|
console.log(data.part_upsert); |
|
2827
|
}); |
|
2828
|
``` |
|
2829
|
|
|
2830
|
### Using `UpsertPart`'s `MutationRef` function |
|
2831
|
|
|
2832
|
```typescript |
|
2833
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2834
|
import { connectorConfig, upsertPartRef, UpsertPartVariables } from '@dataconnect/generated'; |
|
2835
|
|
|
2836
|
// The `UpsertPart` mutation requires an argument of type `UpsertPartVariables`: |
|
2837
|
const upsertPartVars: UpsertPartVariables = { |
|
2838
|
id: ..., |
|
2839
|
name: ..., |
|
2840
|
type: ..., |
|
2841
|
devId: ..., |
|
2842
|
}; |
|
2843
|
|
|
2844
|
// Call the `upsertPartRef()` function to get a reference to the mutation. |
|
2845
|
const ref = upsertPartRef(upsertPartVars); |
|
2846
|
// Variables can be defined inline as well. |
|
2847
|
const ref = upsertPartRef({ id: ..., name: ..., type: ..., devId: ..., }); |
|
2848
|
|
|
2849
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2850
|
const dataConnect = getDataConnect(connectorConfig); |
|
2851
|
const ref = upsertPartRef(dataConnect, upsertPartVars); |
|
2852
|
|
|
2853
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2854
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2855
|
const { data } = await executeMutation(ref); |
|
2856
|
|
|
2857
|
console.log(data.part_upsert); |
|
2858
|
|
|
2859
|
// Or, you can use the `Promise` API. |
|
2860
|
executeMutation(ref).then((response) => { |
|
2861
|
const data = response.data; |
|
2862
|
console.log(data.part_upsert); |
|
2863
|
}); |
|
2864
|
``` |
|
2865
|
|
|
2866
|
## DeletePart |
|
2867
|
You can execute the `DeletePart` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2868
|
```typescript |
|
2869
|
deletePart(vars: DeletePartVariables): MutationPromise<DeletePartData, DeletePartVariables>; |
|
2870
|
|
|
2871
|
interface DeletePartRef { |
|
2872
|
... |
|
2873
|
/* Allow users to create refs without passing in DataConnect */ |
|
2874
|
(vars: DeletePartVariables): MutationRef<DeletePartData, DeletePartVariables>; |
|
2875
|
} |
|
2876
|
export const deletePartRef: DeletePartRef; |
|
2877
|
``` |
|
2878
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2879
|
```typescript |
|
2880
|
deletePart(dc: DataConnect, vars: DeletePartVariables): MutationPromise<DeletePartData, DeletePartVariables>; |
|
2881
|
|
|
2882
|
interface DeletePartRef { |
|
2883
|
... |
|
2884
|
(dc: DataConnect, vars: DeletePartVariables): MutationRef<DeletePartData, DeletePartVariables>; |
|
2885
|
} |
|
2886
|
export const deletePartRef: DeletePartRef; |
|
2887
|
``` |
|
2888
|
|
|
2889
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deletePartRef: |
|
2890
|
```typescript |
|
2891
|
const name = deletePartRef.operationName; |
|
2892
|
console.log(name); |
|
2893
|
``` |
|
2894
|
|
|
2895
|
### Variables |
|
2896
|
The `DeletePart` mutation requires an argument of type `DeletePartVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2897
|
|
|
2898
|
```typescript |
|
2899
|
export interface DeletePartVariables { |
|
2900
|
id: UUIDString; |
|
2901
|
} |
|
2902
|
``` |
|
2903
|
### Return Type |
|
2904
|
Recall that executing the `DeletePart` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
2905
|
|
|
2906
|
The `data` property is an object of type `DeletePartData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
2907
|
```typescript |
|
2908
|
export interface DeletePartData { |
|
2909
|
part_delete?: Part_Key | null; |
|
2910
|
} |
|
2911
|
``` |
|
2912
|
### Using `DeletePart`'s action shortcut function |
|
2913
|
|
|
2914
|
```typescript |
|
2915
|
import { getDataConnect } from 'firebase/data-connect'; |
|
2916
|
import { connectorConfig, deletePart, DeletePartVariables } from '@dataconnect/generated'; |
|
2917
|
|
|
2918
|
// The `DeletePart` mutation requires an argument of type `DeletePartVariables`: |
|
2919
|
const deletePartVars: DeletePartVariables = { |
|
2920
|
id: ..., |
|
2921
|
}; |
|
2922
|
|
|
2923
|
// Call the `deletePart()` function to execute the mutation. |
|
2924
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2925
|
const { data } = await deletePart(deletePartVars); |
|
2926
|
// Variables can be defined inline as well. |
|
2927
|
const { data } = await deletePart({ id: ..., }); |
|
2928
|
|
|
2929
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
2930
|
const dataConnect = getDataConnect(connectorConfig); |
|
2931
|
const { data } = await deletePart(dataConnect, deletePartVars); |
|
2932
|
|
|
2933
|
console.log(data.part_delete); |
|
2934
|
|
|
2935
|
// Or, you can use the `Promise` API. |
|
2936
|
deletePart(deletePartVars).then((response) => { |
|
2937
|
const data = response.data; |
|
2938
|
console.log(data.part_delete); |
|
2939
|
}); |
|
2940
|
``` |
|
2941
|
|
|
2942
|
### Using `DeletePart`'s `MutationRef` function |
|
2943
|
|
|
2944
|
```typescript |
|
2945
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
2946
|
import { connectorConfig, deletePartRef, DeletePartVariables } from '@dataconnect/generated'; |
|
2947
|
|
|
2948
|
// The `DeletePart` mutation requires an argument of type `DeletePartVariables`: |
|
2949
|
const deletePartVars: DeletePartVariables = { |
|
2950
|
id: ..., |
|
2951
|
}; |
|
2952
|
|
|
2953
|
// Call the `deletePartRef()` function to get a reference to the mutation. |
|
2954
|
const ref = deletePartRef(deletePartVars); |
|
2955
|
// Variables can be defined inline as well. |
|
2956
|
const ref = deletePartRef({ id: ..., }); |
|
2957
|
|
|
2958
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
2959
|
const dataConnect = getDataConnect(connectorConfig); |
|
2960
|
const ref = deletePartRef(dataConnect, deletePartVars); |
|
2961
|
|
|
2962
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
2963
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
2964
|
const { data } = await executeMutation(ref); |
|
2965
|
|
|
2966
|
console.log(data.part_delete); |
|
2967
|
|
|
2968
|
// Or, you can use the `Promise` API. |
|
2969
|
executeMutation(ref).then((response) => { |
|
2970
|
const data = response.data; |
|
2971
|
console.log(data.part_delete); |
|
2972
|
}); |
|
2973
|
``` |
|
2974
|
|
|
2975
|
## UpdatePart |
|
2976
|
You can execute the `UpdatePart` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
2977
|
```typescript |
|
2978
|
updatePart(vars: UpdatePartVariables): MutationPromise<UpdatePartData, UpdatePartVariables>; |
|
2979
|
|
|
2980
|
interface UpdatePartRef { |
|
2981
|
... |
|
2982
|
/* Allow users to create refs without passing in DataConnect */ |
|
2983
|
(vars: UpdatePartVariables): MutationRef<UpdatePartData, UpdatePartVariables>; |
|
2984
|
} |
|
2985
|
export const updatePartRef: UpdatePartRef; |
|
2986
|
``` |
|
2987
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
2988
|
```typescript |
|
2989
|
updatePart(dc: DataConnect, vars: UpdatePartVariables): MutationPromise<UpdatePartData, UpdatePartVariables>; |
|
2990
|
|
|
2991
|
interface UpdatePartRef { |
|
2992
|
... |
|
2993
|
(dc: DataConnect, vars: UpdatePartVariables): MutationRef<UpdatePartData, UpdatePartVariables>; |
|
2994
|
} |
|
2995
|
export const updatePartRef: UpdatePartRef; |
|
2996
|
``` |
|
2997
|
|
|
2998
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updatePartRef: |
|
2999
|
```typescript |
|
3000
|
const name = updatePartRef.operationName; |
|
3001
|
console.log(name); |
|
3002
|
``` |
|
3003
|
|
|
3004
|
### Variables |
|
3005
|
The `UpdatePart` mutation requires an argument of type `UpdatePartVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3006
|
|
|
3007
|
```typescript |
|
3008
|
export interface UpdatePartVariables { |
|
3009
|
id: UUIDString; |
|
3010
|
notes: string; |
|
3011
|
} |
|
3012
|
``` |
|
3013
|
### Return Type |
|
3014
|
Recall that executing the `UpdatePart` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3015
|
|
|
3016
|
The `data` property is an object of type `UpdatePartData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3017
|
```typescript |
|
3018
|
export interface UpdatePartData { |
|
3019
|
part_update?: Part_Key | null; |
|
3020
|
} |
|
3021
|
``` |
|
3022
|
### Using `UpdatePart`'s action shortcut function |
|
3023
|
|
|
3024
|
```typescript |
|
3025
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3026
|
import { connectorConfig, updatePart, UpdatePartVariables } from '@dataconnect/generated'; |
|
3027
|
|
|
3028
|
// The `UpdatePart` mutation requires an argument of type `UpdatePartVariables`: |
|
3029
|
const updatePartVars: UpdatePartVariables = { |
|
3030
|
id: ..., |
|
3031
|
notes: ..., |
|
3032
|
}; |
|
3033
|
|
|
3034
|
// Call the `updatePart()` function to execute the mutation. |
|
3035
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3036
|
const { data } = await updatePart(updatePartVars); |
|
3037
|
// Variables can be defined inline as well. |
|
3038
|
const { data } = await updatePart({ id: ..., notes: ..., }); |
|
3039
|
|
|
3040
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3041
|
const dataConnect = getDataConnect(connectorConfig); |
|
3042
|
const { data } = await updatePart(dataConnect, updatePartVars); |
|
3043
|
|
|
3044
|
console.log(data.part_update); |
|
3045
|
|
|
3046
|
// Or, you can use the `Promise` API. |
|
3047
|
updatePart(updatePartVars).then((response) => { |
|
3048
|
const data = response.data; |
|
3049
|
console.log(data.part_update); |
|
3050
|
}); |
|
3051
|
``` |
|
3052
|
|
|
3053
|
### Using `UpdatePart`'s `MutationRef` function |
|
3054
|
|
|
3055
|
```typescript |
|
3056
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3057
|
import { connectorConfig, updatePartRef, UpdatePartVariables } from '@dataconnect/generated'; |
|
3058
|
|
|
3059
|
// The `UpdatePart` mutation requires an argument of type `UpdatePartVariables`: |
|
3060
|
const updatePartVars: UpdatePartVariables = { |
|
3061
|
id: ..., |
|
3062
|
notes: ..., |
|
3063
|
}; |
|
3064
|
|
|
3065
|
// Call the `updatePartRef()` function to get a reference to the mutation. |
|
3066
|
const ref = updatePartRef(updatePartVars); |
|
3067
|
// Variables can be defined inline as well. |
|
3068
|
const ref = updatePartRef({ id: ..., notes: ..., }); |
|
3069
|
|
|
3070
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3071
|
const dataConnect = getDataConnect(connectorConfig); |
|
3072
|
const ref = updatePartRef(dataConnect, updatePartVars); |
|
3073
|
|
|
3074
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3075
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3076
|
const { data } = await executeMutation(ref); |
|
3077
|
|
|
3078
|
console.log(data.part_update); |
|
3079
|
|
|
3080
|
// Or, you can use the `Promise` API. |
|
3081
|
executeMutation(ref).then((response) => { |
|
3082
|
const data = response.data; |
|
3083
|
console.log(data.part_update); |
|
3084
|
}); |
|
3085
|
``` |
|
3086
|
|
|
3087
|
## CreateStep |
|
3088
|
You can execute the `CreateStep` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3089
|
```typescript |
|
3090
|
createStep(vars: CreateStepVariables): MutationPromise<CreateStepData, CreateStepVariables>; |
|
3091
|
|
|
3092
|
interface CreateStepRef { |
|
3093
|
... |
|
3094
|
/* Allow users to create refs without passing in DataConnect */ |
|
3095
|
(vars: CreateStepVariables): MutationRef<CreateStepData, CreateStepVariables>; |
|
3096
|
} |
|
3097
|
export const createStepRef: CreateStepRef; |
|
3098
|
``` |
|
3099
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3100
|
```typescript |
|
3101
|
createStep(dc: DataConnect, vars: CreateStepVariables): MutationPromise<CreateStepData, CreateStepVariables>; |
|
3102
|
|
|
3103
|
interface CreateStepRef { |
|
3104
|
... |
|
3105
|
(dc: DataConnect, vars: CreateStepVariables): MutationRef<CreateStepData, CreateStepVariables>; |
|
3106
|
} |
|
3107
|
export const createStepRef: CreateStepRef; |
|
3108
|
``` |
|
3109
|
|
|
3110
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the createStepRef: |
|
3111
|
```typescript |
|
3112
|
const name = createStepRef.operationName; |
|
3113
|
console.log(name); |
|
3114
|
``` |
|
3115
|
|
|
3116
|
### Variables |
|
3117
|
The `CreateStep` mutation requires an argument of type `CreateStepVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3118
|
|
|
3119
|
```typescript |
|
3120
|
export interface CreateStepVariables { |
|
3121
|
order: number; |
|
3122
|
text: string; |
|
3123
|
guideId: UUIDString; |
|
3124
|
} |
|
3125
|
``` |
|
3126
|
### Return Type |
|
3127
|
Recall that executing the `CreateStep` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3128
|
|
|
3129
|
The `data` property is an object of type `CreateStepData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3130
|
```typescript |
|
3131
|
export interface CreateStepData { |
|
3132
|
step_insert: Step_Key; |
|
3133
|
} |
|
3134
|
``` |
|
3135
|
### Using `CreateStep`'s action shortcut function |
|
3136
|
|
|
3137
|
```typescript |
|
3138
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3139
|
import { connectorConfig, createStep, CreateStepVariables } from '@dataconnect/generated'; |
|
3140
|
|
|
3141
|
// The `CreateStep` mutation requires an argument of type `CreateStepVariables`: |
|
3142
|
const createStepVars: CreateStepVariables = { |
|
3143
|
order: ..., |
|
3144
|
text: ..., |
|
3145
|
guideId: ..., |
|
3146
|
}; |
|
3147
|
|
|
3148
|
// Call the `createStep()` function to execute the mutation. |
|
3149
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3150
|
const { data } = await createStep(createStepVars); |
|
3151
|
// Variables can be defined inline as well. |
|
3152
|
const { data } = await createStep({ order: ..., text: ..., guideId: ..., }); |
|
3153
|
|
|
3154
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3155
|
const dataConnect = getDataConnect(connectorConfig); |
|
3156
|
const { data } = await createStep(dataConnect, createStepVars); |
|
3157
|
|
|
3158
|
console.log(data.step_insert); |
|
3159
|
|
|
3160
|
// Or, you can use the `Promise` API. |
|
3161
|
createStep(createStepVars).then((response) => { |
|
3162
|
const data = response.data; |
|
3163
|
console.log(data.step_insert); |
|
3164
|
}); |
|
3165
|
``` |
|
3166
|
|
|
3167
|
### Using `CreateStep`'s `MutationRef` function |
|
3168
|
|
|
3169
|
```typescript |
|
3170
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3171
|
import { connectorConfig, createStepRef, CreateStepVariables } from '@dataconnect/generated'; |
|
3172
|
|
|
3173
|
// The `CreateStep` mutation requires an argument of type `CreateStepVariables`: |
|
3174
|
const createStepVars: CreateStepVariables = { |
|
3175
|
order: ..., |
|
3176
|
text: ..., |
|
3177
|
guideId: ..., |
|
3178
|
}; |
|
3179
|
|
|
3180
|
// Call the `createStepRef()` function to get a reference to the mutation. |
|
3181
|
const ref = createStepRef(createStepVars); |
|
3182
|
// Variables can be defined inline as well. |
|
3183
|
const ref = createStepRef({ order: ..., text: ..., guideId: ..., }); |
|
3184
|
|
|
3185
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3186
|
const dataConnect = getDataConnect(connectorConfig); |
|
3187
|
const ref = createStepRef(dataConnect, createStepVars); |
|
3188
|
|
|
3189
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3190
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3191
|
const { data } = await executeMutation(ref); |
|
3192
|
|
|
3193
|
console.log(data.step_insert); |
|
3194
|
|
|
3195
|
// Or, you can use the `Promise` API. |
|
3196
|
executeMutation(ref).then((response) => { |
|
3197
|
const data = response.data; |
|
3198
|
console.log(data.step_insert); |
|
3199
|
}); |
|
3200
|
``` |
|
3201
|
|
|
3202
|
## UpsertStep |
|
3203
|
You can execute the `UpsertStep` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3204
|
```typescript |
|
3205
|
upsertStep(vars: UpsertStepVariables): MutationPromise<UpsertStepData, UpsertStepVariables>; |
|
3206
|
|
|
3207
|
interface UpsertStepRef { |
|
3208
|
... |
|
3209
|
/* Allow users to create refs without passing in DataConnect */ |
|
3210
|
(vars: UpsertStepVariables): MutationRef<UpsertStepData, UpsertStepVariables>; |
|
3211
|
} |
|
3212
|
export const upsertStepRef: UpsertStepRef; |
|
3213
|
``` |
|
3214
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3215
|
```typescript |
|
3216
|
upsertStep(dc: DataConnect, vars: UpsertStepVariables): MutationPromise<UpsertStepData, UpsertStepVariables>; |
|
3217
|
|
|
3218
|
interface UpsertStepRef { |
|
3219
|
... |
|
3220
|
(dc: DataConnect, vars: UpsertStepVariables): MutationRef<UpsertStepData, UpsertStepVariables>; |
|
3221
|
} |
|
3222
|
export const upsertStepRef: UpsertStepRef; |
|
3223
|
``` |
|
3224
|
|
|
3225
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the upsertStepRef: |
|
3226
|
```typescript |
|
3227
|
const name = upsertStepRef.operationName; |
|
3228
|
console.log(name); |
|
3229
|
``` |
|
3230
|
|
|
3231
|
### Variables |
|
3232
|
The `UpsertStep` mutation requires an argument of type `UpsertStepVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3233
|
|
|
3234
|
```typescript |
|
3235
|
export interface UpsertStepVariables { |
|
3236
|
id: UUIDString; |
|
3237
|
order: number; |
|
3238
|
text: string; |
|
3239
|
guideId: UUIDString; |
|
3240
|
} |
|
3241
|
``` |
|
3242
|
### Return Type |
|
3243
|
Recall that executing the `UpsertStep` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3244
|
|
|
3245
|
The `data` property is an object of type `UpsertStepData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3246
|
```typescript |
|
3247
|
export interface UpsertStepData { |
|
3248
|
step_upsert: Step_Key; |
|
3249
|
} |
|
3250
|
``` |
|
3251
|
### Using `UpsertStep`'s action shortcut function |
|
3252
|
|
|
3253
|
```typescript |
|
3254
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3255
|
import { connectorConfig, upsertStep, UpsertStepVariables } from '@dataconnect/generated'; |
|
3256
|
|
|
3257
|
// The `UpsertStep` mutation requires an argument of type `UpsertStepVariables`: |
|
3258
|
const upsertStepVars: UpsertStepVariables = { |
|
3259
|
id: ..., |
|
3260
|
order: ..., |
|
3261
|
text: ..., |
|
3262
|
guideId: ..., |
|
3263
|
}; |
|
3264
|
|
|
3265
|
// Call the `upsertStep()` function to execute the mutation. |
|
3266
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3267
|
const { data } = await upsertStep(upsertStepVars); |
|
3268
|
// Variables can be defined inline as well. |
|
3269
|
const { data } = await upsertStep({ id: ..., order: ..., text: ..., guideId: ..., }); |
|
3270
|
|
|
3271
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3272
|
const dataConnect = getDataConnect(connectorConfig); |
|
3273
|
const { data } = await upsertStep(dataConnect, upsertStepVars); |
|
3274
|
|
|
3275
|
console.log(data.step_upsert); |
|
3276
|
|
|
3277
|
// Or, you can use the `Promise` API. |
|
3278
|
upsertStep(upsertStepVars).then((response) => { |
|
3279
|
const data = response.data; |
|
3280
|
console.log(data.step_upsert); |
|
3281
|
}); |
|
3282
|
``` |
|
3283
|
|
|
3284
|
### Using `UpsertStep`'s `MutationRef` function |
|
3285
|
|
|
3286
|
```typescript |
|
3287
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3288
|
import { connectorConfig, upsertStepRef, UpsertStepVariables } from '@dataconnect/generated'; |
|
3289
|
|
|
3290
|
// The `UpsertStep` mutation requires an argument of type `UpsertStepVariables`: |
|
3291
|
const upsertStepVars: UpsertStepVariables = { |
|
3292
|
id: ..., |
|
3293
|
order: ..., |
|
3294
|
text: ..., |
|
3295
|
guideId: ..., |
|
3296
|
}; |
|
3297
|
|
|
3298
|
// Call the `upsertStepRef()` function to get a reference to the mutation. |
|
3299
|
const ref = upsertStepRef(upsertStepVars); |
|
3300
|
// Variables can be defined inline as well. |
|
3301
|
const ref = upsertStepRef({ id: ..., order: ..., text: ..., guideId: ..., }); |
|
3302
|
|
|
3303
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3304
|
const dataConnect = getDataConnect(connectorConfig); |
|
3305
|
const ref = upsertStepRef(dataConnect, upsertStepVars); |
|
3306
|
|
|
3307
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3308
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3309
|
const { data } = await executeMutation(ref); |
|
3310
|
|
|
3311
|
console.log(data.step_upsert); |
|
3312
|
|
|
3313
|
// Or, you can use the `Promise` API. |
|
3314
|
executeMutation(ref).then((response) => { |
|
3315
|
const data = response.data; |
|
3316
|
console.log(data.step_upsert); |
|
3317
|
}); |
|
3318
|
``` |
|
3319
|
|
|
3320
|
## DeleteStep |
|
3321
|
You can execute the `DeleteStep` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3322
|
```typescript |
|
3323
|
deleteStep(vars: DeleteStepVariables): MutationPromise<DeleteStepData, DeleteStepVariables>; |
|
3324
|
|
|
3325
|
interface DeleteStepRef { |
|
3326
|
... |
|
3327
|
/* Allow users to create refs without passing in DataConnect */ |
|
3328
|
(vars: DeleteStepVariables): MutationRef<DeleteStepData, DeleteStepVariables>; |
|
3329
|
} |
|
3330
|
export const deleteStepRef: DeleteStepRef; |
|
3331
|
``` |
|
3332
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3333
|
```typescript |
|
3334
|
deleteStep(dc: DataConnect, vars: DeleteStepVariables): MutationPromise<DeleteStepData, DeleteStepVariables>; |
|
3335
|
|
|
3336
|
interface DeleteStepRef { |
|
3337
|
... |
|
3338
|
(dc: DataConnect, vars: DeleteStepVariables): MutationRef<DeleteStepData, DeleteStepVariables>; |
|
3339
|
} |
|
3340
|
export const deleteStepRef: DeleteStepRef; |
|
3341
|
``` |
|
3342
|
|
|
3343
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deleteStepRef: |
|
3344
|
```typescript |
|
3345
|
const name = deleteStepRef.operationName; |
|
3346
|
console.log(name); |
|
3347
|
``` |
|
3348
|
|
|
3349
|
### Variables |
|
3350
|
The `DeleteStep` mutation requires an argument of type `DeleteStepVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3351
|
|
|
3352
|
```typescript |
|
3353
|
export interface DeleteStepVariables { |
|
3354
|
id: UUIDString; |
|
3355
|
} |
|
3356
|
``` |
|
3357
|
### Return Type |
|
3358
|
Recall that executing the `DeleteStep` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3359
|
|
|
3360
|
The `data` property is an object of type `DeleteStepData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3361
|
```typescript |
|
3362
|
export interface DeleteStepData { |
|
3363
|
step_delete?: Step_Key | null; |
|
3364
|
} |
|
3365
|
``` |
|
3366
|
### Using `DeleteStep`'s action shortcut function |
|
3367
|
|
|
3368
|
```typescript |
|
3369
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3370
|
import { connectorConfig, deleteStep, DeleteStepVariables } from '@dataconnect/generated'; |
|
3371
|
|
|
3372
|
// The `DeleteStep` mutation requires an argument of type `DeleteStepVariables`: |
|
3373
|
const deleteStepVars: DeleteStepVariables = { |
|
3374
|
id: ..., |
|
3375
|
}; |
|
3376
|
|
|
3377
|
// Call the `deleteStep()` function to execute the mutation. |
|
3378
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3379
|
const { data } = await deleteStep(deleteStepVars); |
|
3380
|
// Variables can be defined inline as well. |
|
3381
|
const { data } = await deleteStep({ id: ..., }); |
|
3382
|
|
|
3383
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3384
|
const dataConnect = getDataConnect(connectorConfig); |
|
3385
|
const { data } = await deleteStep(dataConnect, deleteStepVars); |
|
3386
|
|
|
3387
|
console.log(data.step_delete); |
|
3388
|
|
|
3389
|
// Or, you can use the `Promise` API. |
|
3390
|
deleteStep(deleteStepVars).then((response) => { |
|
3391
|
const data = response.data; |
|
3392
|
console.log(data.step_delete); |
|
3393
|
}); |
|
3394
|
``` |
|
3395
|
|
|
3396
|
### Using `DeleteStep`'s `MutationRef` function |
|
3397
|
|
|
3398
|
```typescript |
|
3399
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3400
|
import { connectorConfig, deleteStepRef, DeleteStepVariables } from '@dataconnect/generated'; |
|
3401
|
|
|
3402
|
// The `DeleteStep` mutation requires an argument of type `DeleteStepVariables`: |
|
3403
|
const deleteStepVars: DeleteStepVariables = { |
|
3404
|
id: ..., |
|
3405
|
}; |
|
3406
|
|
|
3407
|
// Call the `deleteStepRef()` function to get a reference to the mutation. |
|
3408
|
const ref = deleteStepRef(deleteStepVars); |
|
3409
|
// Variables can be defined inline as well. |
|
3410
|
const ref = deleteStepRef({ id: ..., }); |
|
3411
|
|
|
3412
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3413
|
const dataConnect = getDataConnect(connectorConfig); |
|
3414
|
const ref = deleteStepRef(dataConnect, deleteStepVars); |
|
3415
|
|
|
3416
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3417
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3418
|
const { data } = await executeMutation(ref); |
|
3419
|
|
|
3420
|
console.log(data.step_delete); |
|
3421
|
|
|
3422
|
// Or, you can use the `Promise` API. |
|
3423
|
executeMutation(ref).then((response) => { |
|
3424
|
const data = response.data; |
|
3425
|
console.log(data.step_delete); |
|
3426
|
}); |
|
3427
|
``` |
|
3428
|
|
|
3429
|
## UpdateStep |
|
3430
|
You can execute the `UpdateStep` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3431
|
```typescript |
|
3432
|
updateStep(vars: UpdateStepVariables): MutationPromise<UpdateStepData, UpdateStepVariables>; |
|
3433
|
|
|
3434
|
interface UpdateStepRef { |
|
3435
|
... |
|
3436
|
/* Allow users to create refs without passing in DataConnect */ |
|
3437
|
(vars: UpdateStepVariables): MutationRef<UpdateStepData, UpdateStepVariables>; |
|
3438
|
} |
|
3439
|
export const updateStepRef: UpdateStepRef; |
|
3440
|
``` |
|
3441
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3442
|
```typescript |
|
3443
|
updateStep(dc: DataConnect, vars: UpdateStepVariables): MutationPromise<UpdateStepData, UpdateStepVariables>; |
|
3444
|
|
|
3445
|
interface UpdateStepRef { |
|
3446
|
... |
|
3447
|
(dc: DataConnect, vars: UpdateStepVariables): MutationRef<UpdateStepData, UpdateStepVariables>; |
|
3448
|
} |
|
3449
|
export const updateStepRef: UpdateStepRef; |
|
3450
|
``` |
|
3451
|
|
|
3452
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updateStepRef: |
|
3453
|
```typescript |
|
3454
|
const name = updateStepRef.operationName; |
|
3455
|
console.log(name); |
|
3456
|
``` |
|
3457
|
|
|
3458
|
### Variables |
|
3459
|
The `UpdateStep` mutation requires an argument of type `UpdateStepVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3460
|
|
|
3461
|
```typescript |
|
3462
|
export interface UpdateStepVariables { |
|
3463
|
id: UUIDString; |
|
3464
|
text: string; |
|
3465
|
} |
|
3466
|
``` |
|
3467
|
### Return Type |
|
3468
|
Recall that executing the `UpdateStep` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3469
|
|
|
3470
|
The `data` property is an object of type `UpdateStepData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3471
|
```typescript |
|
3472
|
export interface UpdateStepData { |
|
3473
|
step_update?: Step_Key | null; |
|
3474
|
} |
|
3475
|
``` |
|
3476
|
### Using `UpdateStep`'s action shortcut function |
|
3477
|
|
|
3478
|
```typescript |
|
3479
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3480
|
import { connectorConfig, updateStep, UpdateStepVariables } from '@dataconnect/generated'; |
|
3481
|
|
|
3482
|
// The `UpdateStep` mutation requires an argument of type `UpdateStepVariables`: |
|
3483
|
const updateStepVars: UpdateStepVariables = { |
|
3484
|
id: ..., |
|
3485
|
text: ..., |
|
3486
|
}; |
|
3487
|
|
|
3488
|
// Call the `updateStep()` function to execute the mutation. |
|
3489
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3490
|
const { data } = await updateStep(updateStepVars); |
|
3491
|
// Variables can be defined inline as well. |
|
3492
|
const { data } = await updateStep({ id: ..., text: ..., }); |
|
3493
|
|
|
3494
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3495
|
const dataConnect = getDataConnect(connectorConfig); |
|
3496
|
const { data } = await updateStep(dataConnect, updateStepVars); |
|
3497
|
|
|
3498
|
console.log(data.step_update); |
|
3499
|
|
|
3500
|
// Or, you can use the `Promise` API. |
|
3501
|
updateStep(updateStepVars).then((response) => { |
|
3502
|
const data = response.data; |
|
3503
|
console.log(data.step_update); |
|
3504
|
}); |
|
3505
|
``` |
|
3506
|
|
|
3507
|
### Using `UpdateStep`'s `MutationRef` function |
|
3508
|
|
|
3509
|
```typescript |
|
3510
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3511
|
import { connectorConfig, updateStepRef, UpdateStepVariables } from '@dataconnect/generated'; |
|
3512
|
|
|
3513
|
// The `UpdateStep` mutation requires an argument of type `UpdateStepVariables`: |
|
3514
|
const updateStepVars: UpdateStepVariables = { |
|
3515
|
id: ..., |
|
3516
|
text: ..., |
|
3517
|
}; |
|
3518
|
|
|
3519
|
// Call the `updateStepRef()` function to get a reference to the mutation. |
|
3520
|
const ref = updateStepRef(updateStepVars); |
|
3521
|
// Variables can be defined inline as well. |
|
3522
|
const ref = updateStepRef({ id: ..., text: ..., }); |
|
3523
|
|
|
3524
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3525
|
const dataConnect = getDataConnect(connectorConfig); |
|
3526
|
const ref = updateStepRef(dataConnect, updateStepVars); |
|
3527
|
|
|
3528
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3529
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3530
|
const { data } = await executeMutation(ref); |
|
3531
|
|
|
3532
|
console.log(data.step_update); |
|
3533
|
|
|
3534
|
// Or, you can use the `Promise` API. |
|
3535
|
executeMutation(ref).then((response) => { |
|
3536
|
const data = response.data; |
|
3537
|
console.log(data.step_update); |
|
3538
|
}); |
|
3539
|
``` |
|
3540
|
|
|
3541
|
## CreateBookmark |
|
3542
|
You can execute the `CreateBookmark` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3543
|
```typescript |
|
3544
|
createBookmark(vars: CreateBookmarkVariables): MutationPromise<CreateBookmarkData, CreateBookmarkVariables>; |
|
3545
|
|
|
3546
|
interface CreateBookmarkRef { |
|
3547
|
... |
|
3548
|
/* Allow users to create refs without passing in DataConnect */ |
|
3549
|
(vars: CreateBookmarkVariables): MutationRef<CreateBookmarkData, CreateBookmarkVariables>; |
|
3550
|
} |
|
3551
|
export const createBookmarkRef: CreateBookmarkRef; |
|
3552
|
``` |
|
3553
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3554
|
```typescript |
|
3555
|
createBookmark(dc: DataConnect, vars: CreateBookmarkVariables): MutationPromise<CreateBookmarkData, CreateBookmarkVariables>; |
|
3556
|
|
|
3557
|
interface CreateBookmarkRef { |
|
3558
|
... |
|
3559
|
(dc: DataConnect, vars: CreateBookmarkVariables): MutationRef<CreateBookmarkData, CreateBookmarkVariables>; |
|
3560
|
} |
|
3561
|
export const createBookmarkRef: CreateBookmarkRef; |
|
3562
|
``` |
|
3563
|
|
|
3564
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the createBookmarkRef: |
|
3565
|
```typescript |
|
3566
|
const name = createBookmarkRef.operationName; |
|
3567
|
console.log(name); |
|
3568
|
``` |
|
3569
|
|
|
3570
|
### Variables |
|
3571
|
The `CreateBookmark` mutation requires an argument of type `CreateBookmarkVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3572
|
|
|
3573
|
```typescript |
|
3574
|
export interface CreateBookmarkVariables { |
|
3575
|
guideId: UUIDString; |
|
3576
|
} |
|
3577
|
``` |
|
3578
|
### Return Type |
|
3579
|
Recall that executing the `CreateBookmark` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3580
|
|
|
3581
|
The `data` property is an object of type `CreateBookmarkData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3582
|
```typescript |
|
3583
|
export interface CreateBookmarkData { |
|
3584
|
userBookmark_insert: UserBookmark_Key; |
|
3585
|
} |
|
3586
|
``` |
|
3587
|
### Using `CreateBookmark`'s action shortcut function |
|
3588
|
|
|
3589
|
```typescript |
|
3590
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3591
|
import { connectorConfig, createBookmark, CreateBookmarkVariables } from '@dataconnect/generated'; |
|
3592
|
|
|
3593
|
// The `CreateBookmark` mutation requires an argument of type `CreateBookmarkVariables`: |
|
3594
|
const createBookmarkVars: CreateBookmarkVariables = { |
|
3595
|
guideId: ..., |
|
3596
|
}; |
|
3597
|
|
|
3598
|
// Call the `createBookmark()` function to execute the mutation. |
|
3599
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3600
|
const { data } = await createBookmark(createBookmarkVars); |
|
3601
|
// Variables can be defined inline as well. |
|
3602
|
const { data } = await createBookmark({ guideId: ..., }); |
|
3603
|
|
|
3604
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3605
|
const dataConnect = getDataConnect(connectorConfig); |
|
3606
|
const { data } = await createBookmark(dataConnect, createBookmarkVars); |
|
3607
|
|
|
3608
|
console.log(data.userBookmark_insert); |
|
3609
|
|
|
3610
|
// Or, you can use the `Promise` API. |
|
3611
|
createBookmark(createBookmarkVars).then((response) => { |
|
3612
|
const data = response.data; |
|
3613
|
console.log(data.userBookmark_insert); |
|
3614
|
}); |
|
3615
|
``` |
|
3616
|
|
|
3617
|
### Using `CreateBookmark`'s `MutationRef` function |
|
3618
|
|
|
3619
|
```typescript |
|
3620
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3621
|
import { connectorConfig, createBookmarkRef, CreateBookmarkVariables } from '@dataconnect/generated'; |
|
3622
|
|
|
3623
|
// The `CreateBookmark` mutation requires an argument of type `CreateBookmarkVariables`: |
|
3624
|
const createBookmarkVars: CreateBookmarkVariables = { |
|
3625
|
guideId: ..., |
|
3626
|
}; |
|
3627
|
|
|
3628
|
// Call the `createBookmarkRef()` function to get a reference to the mutation. |
|
3629
|
const ref = createBookmarkRef(createBookmarkVars); |
|
3630
|
// Variables can be defined inline as well. |
|
3631
|
const ref = createBookmarkRef({ guideId: ..., }); |
|
3632
|
|
|
3633
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3634
|
const dataConnect = getDataConnect(connectorConfig); |
|
3635
|
const ref = createBookmarkRef(dataConnect, createBookmarkVars); |
|
3636
|
|
|
3637
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3638
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3639
|
const { data } = await executeMutation(ref); |
|
3640
|
|
|
3641
|
console.log(data.userBookmark_insert); |
|
3642
|
|
|
3643
|
// Or, you can use the `Promise` API. |
|
3644
|
executeMutation(ref).then((response) => { |
|
3645
|
const data = response.data; |
|
3646
|
console.log(data.userBookmark_insert); |
|
3647
|
}); |
|
3648
|
``` |
|
3649
|
|
|
3650
|
## UpsertBookmark |
|
3651
|
You can execute the `UpsertBookmark` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3652
|
```typescript |
|
3653
|
upsertBookmark(vars: UpsertBookmarkVariables): MutationPromise<UpsertBookmarkData, UpsertBookmarkVariables>; |
|
3654
|
|
|
3655
|
interface UpsertBookmarkRef { |
|
3656
|
... |
|
3657
|
/* Allow users to create refs without passing in DataConnect */ |
|
3658
|
(vars: UpsertBookmarkVariables): MutationRef<UpsertBookmarkData, UpsertBookmarkVariables>; |
|
3659
|
} |
|
3660
|
export const upsertBookmarkRef: UpsertBookmarkRef; |
|
3661
|
``` |
|
3662
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3663
|
```typescript |
|
3664
|
upsertBookmark(dc: DataConnect, vars: UpsertBookmarkVariables): MutationPromise<UpsertBookmarkData, UpsertBookmarkVariables>; |
|
3665
|
|
|
3666
|
interface UpsertBookmarkRef { |
|
3667
|
... |
|
3668
|
(dc: DataConnect, vars: UpsertBookmarkVariables): MutationRef<UpsertBookmarkData, UpsertBookmarkVariables>; |
|
3669
|
} |
|
3670
|
export const upsertBookmarkRef: UpsertBookmarkRef; |
|
3671
|
``` |
|
3672
|
|
|
3673
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the upsertBookmarkRef: |
|
3674
|
```typescript |
|
3675
|
const name = upsertBookmarkRef.operationName; |
|
3676
|
console.log(name); |
|
3677
|
``` |
|
3678
|
|
|
3679
|
### Variables |
|
3680
|
The `UpsertBookmark` mutation requires an argument of type `UpsertBookmarkVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3681
|
|
|
3682
|
```typescript |
|
3683
|
export interface UpsertBookmarkVariables { |
|
3684
|
id: UUIDString; |
|
3685
|
guideId: UUIDString; |
|
3686
|
} |
|
3687
|
``` |
|
3688
|
### Return Type |
|
3689
|
Recall that executing the `UpsertBookmark` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3690
|
|
|
3691
|
The `data` property is an object of type `UpsertBookmarkData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3692
|
```typescript |
|
3693
|
export interface UpsertBookmarkData { |
|
3694
|
userBookmark_upsert: UserBookmark_Key; |
|
3695
|
} |
|
3696
|
``` |
|
3697
|
### Using `UpsertBookmark`'s action shortcut function |
|
3698
|
|
|
3699
|
```typescript |
|
3700
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3701
|
import { connectorConfig, upsertBookmark, UpsertBookmarkVariables } from '@dataconnect/generated'; |
|
3702
|
|
|
3703
|
// The `UpsertBookmark` mutation requires an argument of type `UpsertBookmarkVariables`: |
|
3704
|
const upsertBookmarkVars: UpsertBookmarkVariables = { |
|
3705
|
id: ..., |
|
3706
|
guideId: ..., |
|
3707
|
}; |
|
3708
|
|
|
3709
|
// Call the `upsertBookmark()` function to execute the mutation. |
|
3710
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3711
|
const { data } = await upsertBookmark(upsertBookmarkVars); |
|
3712
|
// Variables can be defined inline as well. |
|
3713
|
const { data } = await upsertBookmark({ id: ..., guideId: ..., }); |
|
3714
|
|
|
3715
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3716
|
const dataConnect = getDataConnect(connectorConfig); |
|
3717
|
const { data } = await upsertBookmark(dataConnect, upsertBookmarkVars); |
|
3718
|
|
|
3719
|
console.log(data.userBookmark_upsert); |
|
3720
|
|
|
3721
|
// Or, you can use the `Promise` API. |
|
3722
|
upsertBookmark(upsertBookmarkVars).then((response) => { |
|
3723
|
const data = response.data; |
|
3724
|
console.log(data.userBookmark_upsert); |
|
3725
|
}); |
|
3726
|
``` |
|
3727
|
|
|
3728
|
### Using `UpsertBookmark`'s `MutationRef` function |
|
3729
|
|
|
3730
|
```typescript |
|
3731
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3732
|
import { connectorConfig, upsertBookmarkRef, UpsertBookmarkVariables } from '@dataconnect/generated'; |
|
3733
|
|
|
3734
|
// The `UpsertBookmark` mutation requires an argument of type `UpsertBookmarkVariables`: |
|
3735
|
const upsertBookmarkVars: UpsertBookmarkVariables = { |
|
3736
|
id: ..., |
|
3737
|
guideId: ..., |
|
3738
|
}; |
|
3739
|
|
|
3740
|
// Call the `upsertBookmarkRef()` function to get a reference to the mutation. |
|
3741
|
const ref = upsertBookmarkRef(upsertBookmarkVars); |
|
3742
|
// Variables can be defined inline as well. |
|
3743
|
const ref = upsertBookmarkRef({ id: ..., guideId: ..., }); |
|
3744
|
|
|
3745
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3746
|
const dataConnect = getDataConnect(connectorConfig); |
|
3747
|
const ref = upsertBookmarkRef(dataConnect, upsertBookmarkVars); |
|
3748
|
|
|
3749
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3750
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3751
|
const { data } = await executeMutation(ref); |
|
3752
|
|
|
3753
|
console.log(data.userBookmark_upsert); |
|
3754
|
|
|
3755
|
// Or, you can use the `Promise` API. |
|
3756
|
executeMutation(ref).then((response) => { |
|
3757
|
const data = response.data; |
|
3758
|
console.log(data.userBookmark_upsert); |
|
3759
|
}); |
|
3760
|
``` |
|
3761
|
|
|
3762
|
## DeleteBookmark |
|
3763
|
You can execute the `DeleteBookmark` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3764
|
```typescript |
|
3765
|
deleteBookmark(vars: DeleteBookmarkVariables): MutationPromise<DeleteBookmarkData, DeleteBookmarkVariables>; |
|
3766
|
|
|
3767
|
interface DeleteBookmarkRef { |
|
3768
|
... |
|
3769
|
/* Allow users to create refs without passing in DataConnect */ |
|
3770
|
(vars: DeleteBookmarkVariables): MutationRef<DeleteBookmarkData, DeleteBookmarkVariables>; |
|
3771
|
} |
|
3772
|
export const deleteBookmarkRef: DeleteBookmarkRef; |
|
3773
|
``` |
|
3774
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3775
|
```typescript |
|
3776
|
deleteBookmark(dc: DataConnect, vars: DeleteBookmarkVariables): MutationPromise<DeleteBookmarkData, DeleteBookmarkVariables>; |
|
3777
|
|
|
3778
|
interface DeleteBookmarkRef { |
|
3779
|
... |
|
3780
|
(dc: DataConnect, vars: DeleteBookmarkVariables): MutationRef<DeleteBookmarkData, DeleteBookmarkVariables>; |
|
3781
|
} |
|
3782
|
export const deleteBookmarkRef: DeleteBookmarkRef; |
|
3783
|
``` |
|
3784
|
|
|
3785
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the deleteBookmarkRef: |
|
3786
|
```typescript |
|
3787
|
const name = deleteBookmarkRef.operationName; |
|
3788
|
console.log(name); |
|
3789
|
``` |
|
3790
|
|
|
3791
|
### Variables |
|
3792
|
The `DeleteBookmark` mutation requires an argument of type `DeleteBookmarkVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3793
|
|
|
3794
|
```typescript |
|
3795
|
export interface DeleteBookmarkVariables { |
|
3796
|
id: UUIDString; |
|
3797
|
} |
|
3798
|
``` |
|
3799
|
### Return Type |
|
3800
|
Recall that executing the `DeleteBookmark` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3801
|
|
|
3802
|
The `data` property is an object of type `DeleteBookmarkData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3803
|
```typescript |
|
3804
|
export interface DeleteBookmarkData { |
|
3805
|
userBookmark_delete?: UserBookmark_Key | null; |
|
3806
|
} |
|
3807
|
``` |
|
3808
|
### Using `DeleteBookmark`'s action shortcut function |
|
3809
|
|
|
3810
|
```typescript |
|
3811
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3812
|
import { connectorConfig, deleteBookmark, DeleteBookmarkVariables } from '@dataconnect/generated'; |
|
3813
|
|
|
3814
|
// The `DeleteBookmark` mutation requires an argument of type `DeleteBookmarkVariables`: |
|
3815
|
const deleteBookmarkVars: DeleteBookmarkVariables = { |
|
3816
|
id: ..., |
|
3817
|
}; |
|
3818
|
|
|
3819
|
// Call the `deleteBookmark()` function to execute the mutation. |
|
3820
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3821
|
const { data } = await deleteBookmark(deleteBookmarkVars); |
|
3822
|
// Variables can be defined inline as well. |
|
3823
|
const { data } = await deleteBookmark({ id: ..., }); |
|
3824
|
|
|
3825
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3826
|
const dataConnect = getDataConnect(connectorConfig); |
|
3827
|
const { data } = await deleteBookmark(dataConnect, deleteBookmarkVars); |
|
3828
|
|
|
3829
|
console.log(data.userBookmark_delete); |
|
3830
|
|
|
3831
|
// Or, you can use the `Promise` API. |
|
3832
|
deleteBookmark(deleteBookmarkVars).then((response) => { |
|
3833
|
const data = response.data; |
|
3834
|
console.log(data.userBookmark_delete); |
|
3835
|
}); |
|
3836
|
``` |
|
3837
|
|
|
3838
|
### Using `DeleteBookmark`'s `MutationRef` function |
|
3839
|
|
|
3840
|
```typescript |
|
3841
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3842
|
import { connectorConfig, deleteBookmarkRef, DeleteBookmarkVariables } from '@dataconnect/generated'; |
|
3843
|
|
|
3844
|
// The `DeleteBookmark` mutation requires an argument of type `DeleteBookmarkVariables`: |
|
3845
|
const deleteBookmarkVars: DeleteBookmarkVariables = { |
|
3846
|
id: ..., |
|
3847
|
}; |
|
3848
|
|
|
3849
|
// Call the `deleteBookmarkRef()` function to get a reference to the mutation. |
|
3850
|
const ref = deleteBookmarkRef(deleteBookmarkVars); |
|
3851
|
// Variables can be defined inline as well. |
|
3852
|
const ref = deleteBookmarkRef({ id: ..., }); |
|
3853
|
|
|
3854
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3855
|
const dataConnect = getDataConnect(connectorConfig); |
|
3856
|
const ref = deleteBookmarkRef(dataConnect, deleteBookmarkVars); |
|
3857
|
|
|
3858
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3859
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3860
|
const { data } = await executeMutation(ref); |
|
3861
|
|
|
3862
|
console.log(data.userBookmark_delete); |
|
3863
|
|
|
3864
|
// Or, you can use the `Promise` API. |
|
3865
|
executeMutation(ref).then((response) => { |
|
3866
|
const data = response.data; |
|
3867
|
console.log(data.userBookmark_delete); |
|
3868
|
}); |
|
3869
|
``` |
|
3870
|
|
|
3871
|
## UpdateBookmark |
|
3872
|
You can execute the `UpdateBookmark` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [dataconnect-generated/index.d.ts](./index.d.ts): |
|
3873
|
```typescript |
|
3874
|
updateBookmark(vars: UpdateBookmarkVariables): MutationPromise<UpdateBookmarkData, UpdateBookmarkVariables>; |
|
3875
|
|
|
3876
|
interface UpdateBookmarkRef { |
|
3877
|
... |
|
3878
|
/* Allow users to create refs without passing in DataConnect */ |
|
3879
|
(vars: UpdateBookmarkVariables): MutationRef<UpdateBookmarkData, UpdateBookmarkVariables>; |
|
3880
|
} |
|
3881
|
export const updateBookmarkRef: UpdateBookmarkRef; |
|
3882
|
``` |
|
3883
|
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function. |
|
3884
|
```typescript |
|
3885
|
updateBookmark(dc: DataConnect, vars: UpdateBookmarkVariables): MutationPromise<UpdateBookmarkData, UpdateBookmarkVariables>; |
|
3886
|
|
|
3887
|
interface UpdateBookmarkRef { |
|
3888
|
... |
|
3889
|
(dc: DataConnect, vars: UpdateBookmarkVariables): MutationRef<UpdateBookmarkData, UpdateBookmarkVariables>; |
|
3890
|
} |
|
3891
|
export const updateBookmarkRef: UpdateBookmarkRef; |
|
3892
|
``` |
|
3893
|
|
|
3894
|
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the updateBookmarkRef: |
|
3895
|
```typescript |
|
3896
|
const name = updateBookmarkRef.operationName; |
|
3897
|
console.log(name); |
|
3898
|
``` |
|
3899
|
|
|
3900
|
### Variables |
|
3901
|
The `UpdateBookmark` mutation requires an argument of type `UpdateBookmarkVariables`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3902
|
|
|
3903
|
```typescript |
|
3904
|
export interface UpdateBookmarkVariables { |
|
3905
|
id: UUIDString; |
|
3906
|
guideId: UUIDString; |
|
3907
|
} |
|
3908
|
``` |
|
3909
|
### Return Type |
|
3910
|
Recall that executing the `UpdateBookmark` mutation returns a `MutationPromise` that resolves to an object with a `data` property. |
|
3911
|
|
|
3912
|
The `data` property is an object of type `UpdateBookmarkData`, which is defined in [dataconnect-generated/index.d.ts](./index.d.ts). It has the following fields: |
|
3913
|
```typescript |
|
3914
|
export interface UpdateBookmarkData { |
|
3915
|
userBookmark_update?: UserBookmark_Key | null; |
|
3916
|
} |
|
3917
|
``` |
|
3918
|
### Using `UpdateBookmark`'s action shortcut function |
|
3919
|
|
|
3920
|
```typescript |
|
3921
|
import { getDataConnect } from 'firebase/data-connect'; |
|
3922
|
import { connectorConfig, updateBookmark, UpdateBookmarkVariables } from '@dataconnect/generated'; |
|
3923
|
|
|
3924
|
// The `UpdateBookmark` mutation requires an argument of type `UpdateBookmarkVariables`: |
|
3925
|
const updateBookmarkVars: UpdateBookmarkVariables = { |
|
3926
|
id: ..., |
|
3927
|
guideId: ..., |
|
3928
|
}; |
|
3929
|
|
|
3930
|
// Call the `updateBookmark()` function to execute the mutation. |
|
3931
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3932
|
const { data } = await updateBookmark(updateBookmarkVars); |
|
3933
|
// Variables can be defined inline as well. |
|
3934
|
const { data } = await updateBookmark({ id: ..., guideId: ..., }); |
|
3935
|
|
|
3936
|
// You can also pass in a `DataConnect` instance to the action shortcut function. |
|
3937
|
const dataConnect = getDataConnect(connectorConfig); |
|
3938
|
const { data } = await updateBookmark(dataConnect, updateBookmarkVars); |
|
3939
|
|
|
3940
|
console.log(data.userBookmark_update); |
|
3941
|
|
|
3942
|
// Or, you can use the `Promise` API. |
|
3943
|
updateBookmark(updateBookmarkVars).then((response) => { |
|
3944
|
const data = response.data; |
|
3945
|
console.log(data.userBookmark_update); |
|
3946
|
}); |
|
3947
|
``` |
|
3948
|
|
|
3949
|
### Using `UpdateBookmark`'s `MutationRef` function |
|
3950
|
|
|
3951
|
```typescript |
|
3952
|
import { getDataConnect, executeMutation } from 'firebase/data-connect'; |
|
3953
|
import { connectorConfig, updateBookmarkRef, UpdateBookmarkVariables } from '@dataconnect/generated'; |
|
3954
|
|
|
3955
|
// The `UpdateBookmark` mutation requires an argument of type `UpdateBookmarkVariables`: |
|
3956
|
const updateBookmarkVars: UpdateBookmarkVariables = { |
|
3957
|
id: ..., |
|
3958
|
guideId: ..., |
|
3959
|
}; |
|
3960
|
|
|
3961
|
// Call the `updateBookmarkRef()` function to get a reference to the mutation. |
|
3962
|
const ref = updateBookmarkRef(updateBookmarkVars); |
|
3963
|
// Variables can be defined inline as well. |
|
3964
|
const ref = updateBookmarkRef({ id: ..., guideId: ..., }); |
|
3965
|
|
|
3966
|
// You can also pass in a `DataConnect` instance to the `MutationRef` function. |
|
3967
|
const dataConnect = getDataConnect(connectorConfig); |
|
3968
|
const ref = updateBookmarkRef(dataConnect, updateBookmarkVars); |
|
3969
|
|
|
3970
|
// Call `executeMutation()` on the reference to execute the mutation. |
|
3971
|
// You can use the `await` keyword to wait for the promise to resolve. |
|
3972
|
const { data } = await executeMutation(ref); |
|
3973
|
|
|
3974
|
console.log(data.userBookmark_update); |
|
3975
|
|
|
3976
|
// Or, you can use the `Promise` API. |
|
3977
|
executeMutation(ref).then((response) => { |
|
3978
|
const data = response.data; |
|
3979
|
console.log(data.userBookmark_update); |
|
3980
|
}); |
|
3981
|
``` |
|
3982
|
|