Generated TypeScript README
This README will guide you through the process of using the generated JavaScript SDK package for the connector krow-connector. It will also provide examples on how to use your generated SDK to call your Data Connect queries and mutations.
If you're looking for the React README, you can find it at dataconnect-generated/react/README.md
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.
Table of Contents
Accessing the connector
A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector krow-connector. You can find more information about connectors in the Data Connect documentation.
You can use this generated SDK by importing from the package @dataconnect/generated as shown below. Both CommonJS and ESM imports are supported.
You can also follow the instructions from the Data Connect documentation.
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig } from '@dataconnect/generated';
const dataConnect = getDataConnect(connectorConfig);
Connecting to the local Emulator
By default, the connector will connect to the production service.
To connect to the emulator, you can use the following code. You can also follow the emulator instructions from the Data Connect documentation.
import { connectDataConnectEmulator, getDataConnect } from 'firebase/data-connect';
import { connectorConfig } from '@dataconnect/generated';
const dataConnect = getDataConnect(connectorConfig);
connectDataConnectEmulator(dataConnect, 'localhost', 9399);
After it's initialized, you can call your Data Connect queries and mutations from your generated SDK.
Queries
There are two ways to execute a Data Connect Query using the generated Web SDK:
- Using a Query Reference function, which returns a
QueryRef- The
QueryRefcan be used as an argument toexecuteQuery(), which will execute the Query and return aQueryPromise
- The
- Using an action shortcut function, which returns a
QueryPromise- Calling the action shortcut function will execute the Query and return a
QueryPromise
- Calling the action shortcut function will execute the Query and return a
The following is true for both the action shortcut function and the QueryRef function:
- The
QueryPromisereturned will resolve to the result of the Query once it has finished executing - If the Query accepts arguments, both the action shortcut function and the
QueryReffunction accept a single argument: an object that contains all the required variables (and the optional variables) for the Query - Both functions can be called with or without passing in a
DataConnectinstance as an argument. If noDataConnectargument is passed in, then the generated SDK will callgetDataConnect(connectorConfig)behind the scenes for you.
Below are examples of how to use the krow-connector connector's generated functions to execute each query. You can also follow the examples from the Data Connect documentation.
listVendor
You can execute the listVendor 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:
listVendor(): QueryPromise<ListVendorData, undefined>;
interface ListVendorRef {
...
/* Allow users to create refs without passing in DataConnect */
(): QueryRef<ListVendorData, undefined>;
}
export const listVendorRef: ListVendorRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
listVendor(dc: DataConnect): QueryPromise<ListVendorData, undefined>;
interface ListVendorRef {
...
(dc: DataConnect): QueryRef<ListVendorData, undefined>;
}
export const listVendorRef: ListVendorRef;
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 listVendorRef:
const name = listVendorRef.operationName;
console.log(name);
Variables
The listVendor query has no variables.
Return Type
Recall that executing the listVendor query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type ListVendorData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface ListVendorData {
vendors: ({
id: UUIDString;
vendorNumber: string;
legalName: string;
region: VendorRegion;
platformType: VendorPlatformType;
primaryContactEmail: string;
approvalStatus: VendorApprovalStatus;
isActive?: boolean | null;
} & Vendor_Key)[];
}
Using listVendor's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, listVendor } from '@dataconnect/generated';
// Call the `listVendor()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await listVendor();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await listVendor(dataConnect);
console.log(data.vendors);
// Or, you can use the `Promise` API.
listVendor().then((response) => {
const data = response.data;
console.log(data.vendors);
});
Using listVendor's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, listVendorRef } from '@dataconnect/generated';
// Call the `listVendorRef()` function to get a reference to the query.
const ref = listVendorRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = listVendorRef(dataConnect);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.vendors);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.vendors);
});
getVendorById
You can execute the getVendorById 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:
getVendorById(vars: GetVendorByIdVariables): QueryPromise<GetVendorByIdData, GetVendorByIdVariables>;
interface GetVendorByIdRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: GetVendorByIdVariables): QueryRef<GetVendorByIdData, GetVendorByIdVariables>;
}
export const getVendorByIdRef: GetVendorByIdRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
getVendorById(dc: DataConnect, vars: GetVendorByIdVariables): QueryPromise<GetVendorByIdData, GetVendorByIdVariables>;
interface GetVendorByIdRef {
...
(dc: DataConnect, vars: GetVendorByIdVariables): QueryRef<GetVendorByIdData, GetVendorByIdVariables>;
}
export const getVendorByIdRef: GetVendorByIdRef;
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 getVendorByIdRef:
const name = getVendorByIdRef.operationName;
console.log(name);
Variables
The getVendorById query requires an argument of type GetVendorByIdVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface GetVendorByIdVariables {
id: UUIDString;
}
Return Type
Recall that executing the getVendorById query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type GetVendorByIdData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface GetVendorByIdData {
vendor?: {
id: UUIDString;
vendorNumber: string;
legalName: string;
region: VendorRegion;
platformType: VendorPlatformType;
primaryContactEmail: string;
approvalStatus: VendorApprovalStatus;
isActive?: boolean | null;
} & Vendor_Key;
}
Using getVendorById's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, getVendorById, GetVendorByIdVariables } from '@dataconnect/generated';
// The `getVendorById` query requires an argument of type `GetVendorByIdVariables`:
const getVendorByIdVars: GetVendorByIdVariables = {
id: ...,
};
// Call the `getVendorById()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await getVendorById(getVendorByIdVars);
// Variables can be defined inline as well.
const { data } = await getVendorById({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await getVendorById(dataConnect, getVendorByIdVars);
console.log(data.vendor);
// Or, you can use the `Promise` API.
getVendorById(getVendorByIdVars).then((response) => {
const data = response.data;
console.log(data.vendor);
});
Using getVendorById's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, getVendorByIdRef, GetVendorByIdVariables } from '@dataconnect/generated';
// The `getVendorById` query requires an argument of type `GetVendorByIdVariables`:
const getVendorByIdVars: GetVendorByIdVariables = {
id: ...,
};
// Call the `getVendorByIdRef()` function to get a reference to the query.
const ref = getVendorByIdRef(getVendorByIdVars);
// Variables can be defined inline as well.
const ref = getVendorByIdRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = getVendorByIdRef(dataConnect, getVendorByIdVars);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.vendor);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.vendor);
});
filterVendors
You can execute the filterVendors 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:
filterVendors(vars?: FilterVendorsVariables): QueryPromise<FilterVendorsData, FilterVendorsVariables>;
interface FilterVendorsRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars?: FilterVendorsVariables): QueryRef<FilterVendorsData, FilterVendorsVariables>;
}
export const filterVendorsRef: FilterVendorsRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
filterVendors(dc: DataConnect, vars?: FilterVendorsVariables): QueryPromise<FilterVendorsData, FilterVendorsVariables>;
interface FilterVendorsRef {
...
(dc: DataConnect, vars?: FilterVendorsVariables): QueryRef<FilterVendorsData, FilterVendorsVariables>;
}
export const filterVendorsRef: FilterVendorsRef;
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 filterVendorsRef:
const name = filterVendorsRef.operationName;
console.log(name);
Variables
The filterVendors query has an optional argument of type FilterVendorsVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface FilterVendorsVariables {
region?: VendorRegion | null;
approvalStatus?: VendorApprovalStatus | null;
isActive?: boolean | null;
vendorNumber?: string | null;
primaryContactEmail?: string | null;
legalName?: string | null;
platformType?: VendorPlatformType | null;
}
Return Type
Recall that executing the filterVendors query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type FilterVendorsData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface FilterVendorsData {
vendors: ({
id: UUIDString;
vendorNumber: string;
legalName: string;
region: VendorRegion;
platformType: VendorPlatformType;
primaryContactEmail: string;
approvalStatus: VendorApprovalStatus;
isActive?: boolean | null;
} & Vendor_Key)[];
}
Using filterVendors's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, filterVendors, FilterVendorsVariables } from '@dataconnect/generated';
// The `filterVendors` query has an optional argument of type `FilterVendorsVariables`:
const filterVendorsVars: FilterVendorsVariables = {
region: ..., // optional
approvalStatus: ..., // optional
isActive: ..., // optional
vendorNumber: ..., // optional
primaryContactEmail: ..., // optional
legalName: ..., // optional
platformType: ..., // optional
};
// Call the `filterVendors()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await filterVendors(filterVendorsVars);
// Variables can be defined inline as well.
const { data } = await filterVendors({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., });
// Since all variables are optional for this query, you can omit the `FilterVendorsVariables` argument.
const { data } = await filterVendors();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await filterVendors(dataConnect, filterVendorsVars);
console.log(data.vendors);
// Or, you can use the `Promise` API.
filterVendors(filterVendorsVars).then((response) => {
const data = response.data;
console.log(data.vendors);
});
Using filterVendors's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, filterVendorsRef, FilterVendorsVariables } from '@dataconnect/generated';
// The `filterVendors` query has an optional argument of type `FilterVendorsVariables`:
const filterVendorsVars: FilterVendorsVariables = {
region: ..., // optional
approvalStatus: ..., // optional
isActive: ..., // optional
vendorNumber: ..., // optional
primaryContactEmail: ..., // optional
legalName: ..., // optional
platformType: ..., // optional
};
// Call the `filterVendorsRef()` function to get a reference to the query.
const ref = filterVendorsRef(filterVendorsVars);
// Variables can be defined inline as well.
const ref = filterVendorsRef({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., });
// Since all variables are optional for this query, you can omit the `FilterVendorsVariables` argument.
const ref = filterVendorsRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = filterVendorsRef(dataConnect, filterVendorsVars);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.vendors);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.vendors);
});
listVendorRate
You can execute the listVendorRate 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:
listVendorRate(): QueryPromise<ListVendorRateData, undefined>;
interface ListVendorRateRef {
...
/* Allow users to create refs without passing in DataConnect */
(): QueryRef<ListVendorRateData, undefined>;
}
export const listVendorRateRef: ListVendorRateRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
listVendorRate(dc: DataConnect): QueryPromise<ListVendorRateData, undefined>;
interface ListVendorRateRef {
...
(dc: DataConnect): QueryRef<ListVendorRateData, undefined>;
}
export const listVendorRateRef: ListVendorRateRef;
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 listVendorRateRef:
const name = listVendorRateRef.operationName;
console.log(name);
Variables
The listVendorRate query has no variables.
Return Type
Recall that executing the listVendorRate query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type ListVendorRateData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface ListVendorRateData {
vendorRates: ({
id: UUIDString;
vendorName: string;
category: VendorRateCategory;
roleName: string;
employeeWage: number;
markupPercentage?: number | null;
vendorFeePercentage?: number | null;
clientRate: number;
} & VendorRate_Key)[];
}
Using listVendorRate's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, listVendorRate } from '@dataconnect/generated';
// Call the `listVendorRate()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await listVendorRate();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await listVendorRate(dataConnect);
console.log(data.vendorRates);
// Or, you can use the `Promise` API.
listVendorRate().then((response) => {
const data = response.data;
console.log(data.vendorRates);
});
Using listVendorRate's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, listVendorRateRef } from '@dataconnect/generated';
// Call the `listVendorRateRef()` function to get a reference to the query.
const ref = listVendorRateRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = listVendorRateRef(dataConnect);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.vendorRates);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.vendorRates);
});
getVendorRateById
You can execute the getVendorRateById 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:
getVendorRateById(vars: GetVendorRateByIdVariables): QueryPromise<GetVendorRateByIdData, GetVendorRateByIdVariables>;
interface GetVendorRateByIdRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: GetVendorRateByIdVariables): QueryRef<GetVendorRateByIdData, GetVendorRateByIdVariables>;
}
export const getVendorRateByIdRef: GetVendorRateByIdRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
getVendorRateById(dc: DataConnect, vars: GetVendorRateByIdVariables): QueryPromise<GetVendorRateByIdData, GetVendorRateByIdVariables>;
interface GetVendorRateByIdRef {
...
(dc: DataConnect, vars: GetVendorRateByIdVariables): QueryRef<GetVendorRateByIdData, GetVendorRateByIdVariables>;
}
export const getVendorRateByIdRef: GetVendorRateByIdRef;
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 getVendorRateByIdRef:
const name = getVendorRateByIdRef.operationName;
console.log(name);
Variables
The getVendorRateById query requires an argument of type GetVendorRateByIdVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface GetVendorRateByIdVariables {
id: UUIDString;
}
Return Type
Recall that executing the getVendorRateById query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type GetVendorRateByIdData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface GetVendorRateByIdData {
vendorRate?: {
id: UUIDString;
vendorName: string;
category: VendorRateCategory;
roleName: string;
employeeWage: number;
markupPercentage?: number | null;
vendorFeePercentage?: number | null;
clientRate: number;
createdDate?: TimestampString | null;
updatedDate?: TimestampString | null;
createdBy?: string | null;
} & VendorRate_Key;
}
Using getVendorRateById's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, getVendorRateById, GetVendorRateByIdVariables } from '@dataconnect/generated';
// The `getVendorRateById` query requires an argument of type `GetVendorRateByIdVariables`:
const getVendorRateByIdVars: GetVendorRateByIdVariables = {
id: ...,
};
// Call the `getVendorRateById()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await getVendorRateById(getVendorRateByIdVars);
// Variables can be defined inline as well.
const { data } = await getVendorRateById({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await getVendorRateById(dataConnect, getVendorRateByIdVars);
console.log(data.vendorRate);
// Or, you can use the `Promise` API.
getVendorRateById(getVendorRateByIdVars).then((response) => {
const data = response.data;
console.log(data.vendorRate);
});
Using getVendorRateById's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, getVendorRateByIdRef, GetVendorRateByIdVariables } from '@dataconnect/generated';
// The `getVendorRateById` query requires an argument of type `GetVendorRateByIdVariables`:
const getVendorRateByIdVars: GetVendorRateByIdVariables = {
id: ...,
};
// Call the `getVendorRateByIdRef()` function to get a reference to the query.
const ref = getVendorRateByIdRef(getVendorRateByIdVars);
// Variables can be defined inline as well.
const ref = getVendorRateByIdRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = getVendorRateByIdRef(dataConnect, getVendorRateByIdVars);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.vendorRate);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.vendorRate);
});
filterVendorRates
You can execute the filterVendorRates 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:
filterVendorRates(vars?: FilterVendorRatesVariables): QueryPromise<FilterVendorRatesData, FilterVendorRatesVariables>;
interface FilterVendorRatesRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars?: FilterVendorRatesVariables): QueryRef<FilterVendorRatesData, FilterVendorRatesVariables>;
}
export const filterVendorRatesRef: FilterVendorRatesRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
filterVendorRates(dc: DataConnect, vars?: FilterVendorRatesVariables): QueryPromise<FilterVendorRatesData, FilterVendorRatesVariables>;
interface FilterVendorRatesRef {
...
(dc: DataConnect, vars?: FilterVendorRatesVariables): QueryRef<FilterVendorRatesData, FilterVendorRatesVariables>;
}
export const filterVendorRatesRef: FilterVendorRatesRef;
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 filterVendorRatesRef:
const name = filterVendorRatesRef.operationName;
console.log(name);
Variables
The filterVendorRates query has an optional argument of type FilterVendorRatesVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface FilterVendorRatesVariables {
vendorName?: string | null;
category?: VendorRateCategory | null;
roleName?: string | null;
minClientRate?: number | null;
maxClientRate?: number | null;
}
Return Type
Recall that executing the filterVendorRates query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type FilterVendorRatesData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface FilterVendorRatesData {
vendorRates: ({
id: UUIDString;
vendorName: string;
category: VendorRateCategory;
roleName: string;
employeeWage: number;
markupPercentage?: number | null;
vendorFeePercentage?: number | null;
clientRate: number;
} & VendorRate_Key)[];
}
Using filterVendorRates's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, filterVendorRates, FilterVendorRatesVariables } from '@dataconnect/generated';
// The `filterVendorRates` query has an optional argument of type `FilterVendorRatesVariables`:
const filterVendorRatesVars: FilterVendorRatesVariables = {
vendorName: ..., // optional
category: ..., // optional
roleName: ..., // optional
minClientRate: ..., // optional
maxClientRate: ..., // optional
};
// Call the `filterVendorRates()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await filterVendorRates(filterVendorRatesVars);
// Variables can be defined inline as well.
const { data } = await filterVendorRates({ vendorName: ..., category: ..., roleName: ..., minClientRate: ..., maxClientRate: ..., });
// Since all variables are optional for this query, you can omit the `FilterVendorRatesVariables` argument.
const { data } = await filterVendorRates();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await filterVendorRates(dataConnect, filterVendorRatesVars);
console.log(data.vendorRates);
// Or, you can use the `Promise` API.
filterVendorRates(filterVendorRatesVars).then((response) => {
const data = response.data;
console.log(data.vendorRates);
});
Using filterVendorRates's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, filterVendorRatesRef, FilterVendorRatesVariables } from '@dataconnect/generated';
// The `filterVendorRates` query has an optional argument of type `FilterVendorRatesVariables`:
const filterVendorRatesVars: FilterVendorRatesVariables = {
vendorName: ..., // optional
category: ..., // optional
roleName: ..., // optional
minClientRate: ..., // optional
maxClientRate: ..., // optional
};
// Call the `filterVendorRatesRef()` function to get a reference to the query.
const ref = filterVendorRatesRef(filterVendorRatesVars);
// Variables can be defined inline as well.
const ref = filterVendorRatesRef({ vendorName: ..., category: ..., roleName: ..., minClientRate: ..., maxClientRate: ..., });
// Since all variables are optional for this query, you can omit the `FilterVendorRatesVariables` argument.
const ref = filterVendorRatesRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = filterVendorRatesRef(dataConnect, filterVendorRatesVars);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.vendorRates);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.vendorRates);
});
listEvents
You can execute the listEvents 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:
listEvents(): QueryPromise<ListEventsData, undefined>;
interface ListEventsRef {
...
/* Allow users to create refs without passing in DataConnect */
(): QueryRef<ListEventsData, undefined>;
}
export const listEventsRef: ListEventsRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
listEvents(dc: DataConnect): QueryPromise<ListEventsData, undefined>;
interface ListEventsRef {
...
(dc: DataConnect): QueryRef<ListEventsData, undefined>;
}
export const listEventsRef: ListEventsRef;
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 listEventsRef:
const name = listEventsRef.operationName;
console.log(name);
Variables
The listEvents query has no variables.
Return Type
Recall that executing the listEvents query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type ListEventsData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface ListEventsData {
events: ({
id: UUIDString;
eventName: string;
status: EventStatus;
date: TimestampString;
isRapid?: boolean | null;
isRecurring?: boolean | null;
isMultiDay?: boolean | null;
recurrenceType?: RecurrenceType | null;
recurrenceStartDate?: TimestampString | null;
recurrenceEndDate?: TimestampString | null;
scatterDates?: string | null;
multiDayStartDate?: TimestampString | null;
multiDayEndDate?: TimestampString | null;
bufferTimeBefore?: number | null;
bufferTimeAfter?: number | null;
conflictDetectionEnabled?: boolean | null;
detectedConflicts?: string | null;
businessId: UUIDString;
businessName?: string | null;
vendorId?: UUIDString | null;
vendorName?: string | null;
hub?: string | null;
eventLocation?: string | null;
contractType?: ContractType | null;
poReference?: string | null;
shifts?: string | null;
addons?: string | null;
total?: number | null;
clientName?: string | null;
clientEmail?: string | null;
clientPhone?: string | null;
invoiceId?: UUIDString | null;
notes?: string | null;
requested?: number | null;
assignedStaff?: string | null;
} & Event_Key)[];
}
Using listEvents's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, listEvents } from '@dataconnect/generated';
// Call the `listEvents()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await listEvents();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await listEvents(dataConnect);
console.log(data.events);
// Or, you can use the `Promise` API.
listEvents().then((response) => {
const data = response.data;
console.log(data.events);
});
Using listEvents's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, listEventsRef } from '@dataconnect/generated';
// Call the `listEventsRef()` function to get a reference to the query.
const ref = listEventsRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = listEventsRef(dataConnect);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.events);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.events);
});
getEventById
You can execute the getEventById 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:
getEventById(vars: GetEventByIdVariables): QueryPromise<GetEventByIdData, GetEventByIdVariables>;
interface GetEventByIdRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: GetEventByIdVariables): QueryRef<GetEventByIdData, GetEventByIdVariables>;
}
export const getEventByIdRef: GetEventByIdRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
getEventById(dc: DataConnect, vars: GetEventByIdVariables): QueryPromise<GetEventByIdData, GetEventByIdVariables>;
interface GetEventByIdRef {
...
(dc: DataConnect, vars: GetEventByIdVariables): QueryRef<GetEventByIdData, GetEventByIdVariables>;
}
export const getEventByIdRef: GetEventByIdRef;
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 getEventByIdRef:
const name = getEventByIdRef.operationName;
console.log(name);
Variables
The getEventById query requires an argument of type GetEventByIdVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface GetEventByIdVariables {
id: UUIDString;
}
Return Type
Recall that executing the getEventById query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type GetEventByIdData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface GetEventByIdData {
event?: {
id: UUIDString;
eventName: string;
status: EventStatus;
date: TimestampString;
isRapid?: boolean | null;
isRecurring?: boolean | null;
isMultiDay?: boolean | null;
recurrenceType?: RecurrenceType | null;
recurrenceStartDate?: TimestampString | null;
recurrenceEndDate?: TimestampString | null;
scatterDates?: string | null;
multiDayStartDate?: TimestampString | null;
multiDayEndDate?: TimestampString | null;
bufferTimeBefore?: number | null;
bufferTimeAfter?: number | null;
conflictDetectionEnabled?: boolean | null;
detectedConflicts?: string | null;
businessId: UUIDString;
businessName?: string | null;
vendorId?: UUIDString | null;
vendorName?: string | null;
hub?: string | null;
eventLocation?: string | null;
contractType?: ContractType | null;
poReference?: string | null;
shifts?: string | null;
addons?: string | null;
total?: number | null;
clientName?: string | null;
clientEmail?: string | null;
clientPhone?: string | null;
invoiceId?: UUIDString | null;
notes?: string | null;
requested?: number | null;
assignedStaff?: string | null;
} & Event_Key;
}
Using getEventById's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, getEventById, GetEventByIdVariables } from '@dataconnect/generated';
// The `getEventById` query requires an argument of type `GetEventByIdVariables`:
const getEventByIdVars: GetEventByIdVariables = {
id: ...,
};
// Call the `getEventById()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await getEventById(getEventByIdVars);
// Variables can be defined inline as well.
const { data } = await getEventById({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await getEventById(dataConnect, getEventByIdVars);
console.log(data.event);
// Or, you can use the `Promise` API.
getEventById(getEventByIdVars).then((response) => {
const data = response.data;
console.log(data.event);
});
Using getEventById's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, getEventByIdRef, GetEventByIdVariables } from '@dataconnect/generated';
// The `getEventById` query requires an argument of type `GetEventByIdVariables`:
const getEventByIdVars: GetEventByIdVariables = {
id: ...,
};
// Call the `getEventByIdRef()` function to get a reference to the query.
const ref = getEventByIdRef(getEventByIdVars);
// Variables can be defined inline as well.
const ref = getEventByIdRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = getEventByIdRef(dataConnect, getEventByIdVars);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.event);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.event);
});
filterEvents
You can execute the filterEvents 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:
filterEvents(vars?: FilterEventsVariables): QueryPromise<FilterEventsData, FilterEventsVariables>;
interface FilterEventsRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars?: FilterEventsVariables): QueryRef<FilterEventsData, FilterEventsVariables>;
}
export const filterEventsRef: FilterEventsRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
filterEvents(dc: DataConnect, vars?: FilterEventsVariables): QueryPromise<FilterEventsData, FilterEventsVariables>;
interface FilterEventsRef {
...
(dc: DataConnect, vars?: FilterEventsVariables): QueryRef<FilterEventsData, FilterEventsVariables>;
}
export const filterEventsRef: FilterEventsRef;
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 filterEventsRef:
const name = filterEventsRef.operationName;
console.log(name);
Variables
The filterEvents query has an optional argument of type FilterEventsVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface FilterEventsVariables {
status?: EventStatus | null;
businessId?: UUIDString | null;
vendorId?: UUIDString | null;
isRecurring?: boolean | null;
isRapid?: boolean | null;
isMultiDay?: boolean | null;
recurrenceType?: RecurrenceType | null;
date?: TimestampString | null;
hub?: string | null;
eventLocation?: string | null;
contractType?: ContractType | null;
clientEmail?: string | null;
}
Return Type
Recall that executing the filterEvents query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type FilterEventsData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface FilterEventsData {
events: ({
id: UUIDString;
eventName: string;
status: EventStatus;
date: TimestampString;
isRapid?: boolean | null;
isRecurring?: boolean | null;
isMultiDay?: boolean | null;
recurrenceType?: RecurrenceType | null;
recurrenceStartDate?: TimestampString | null;
recurrenceEndDate?: TimestampString | null;
scatterDates?: string | null;
multiDayStartDate?: TimestampString | null;
multiDayEndDate?: TimestampString | null;
bufferTimeBefore?: number | null;
bufferTimeAfter?: number | null;
conflictDetectionEnabled?: boolean | null;
detectedConflicts?: string | null;
businessId: UUIDString;
businessName?: string | null;
vendorId?: UUIDString | null;
vendorName?: string | null;
hub?: string | null;
eventLocation?: string | null;
contractType?: ContractType | null;
poReference?: string | null;
shifts?: string | null;
addons?: string | null;
total?: number | null;
clientName?: string | null;
clientEmail?: string | null;
clientPhone?: string | null;
invoiceId?: UUIDString | null;
notes?: string | null;
requested?: number | null;
assignedStaff?: string | null;
} & Event_Key)[];
}
Using filterEvents's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, filterEvents, FilterEventsVariables } from '@dataconnect/generated';
// The `filterEvents` query has an optional argument of type `FilterEventsVariables`:
const filterEventsVars: FilterEventsVariables = {
status: ..., // optional
businessId: ..., // optional
vendorId: ..., // optional
isRecurring: ..., // optional
isRapid: ..., // optional
isMultiDay: ..., // optional
recurrenceType: ..., // optional
date: ..., // optional
hub: ..., // optional
eventLocation: ..., // optional
contractType: ..., // optional
clientEmail: ..., // optional
};
// Call the `filterEvents()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await filterEvents(filterEventsVars);
// Variables can be defined inline as well.
const { data } = await filterEvents({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., });
// Since all variables are optional for this query, you can omit the `FilterEventsVariables` argument.
const { data } = await filterEvents();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await filterEvents(dataConnect, filterEventsVars);
console.log(data.events);
// Or, you can use the `Promise` API.
filterEvents(filterEventsVars).then((response) => {
const data = response.data;
console.log(data.events);
});
Using filterEvents's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, filterEventsRef, FilterEventsVariables } from '@dataconnect/generated';
// The `filterEvents` query has an optional argument of type `FilterEventsVariables`:
const filterEventsVars: FilterEventsVariables = {
status: ..., // optional
businessId: ..., // optional
vendorId: ..., // optional
isRecurring: ..., // optional
isRapid: ..., // optional
isMultiDay: ..., // optional
recurrenceType: ..., // optional
date: ..., // optional
hub: ..., // optional
eventLocation: ..., // optional
contractType: ..., // optional
clientEmail: ..., // optional
};
// Call the `filterEventsRef()` function to get a reference to the query.
const ref = filterEventsRef(filterEventsVars);
// Variables can be defined inline as well.
const ref = filterEventsRef({ status: ..., businessId: ..., vendorId: ..., isRecurring: ..., isRapid: ..., isMultiDay: ..., recurrenceType: ..., date: ..., hub: ..., eventLocation: ..., contractType: ..., clientEmail: ..., });
// Since all variables are optional for this query, you can omit the `FilterEventsVariables` argument.
const ref = filterEventsRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = filterEventsRef(dataConnect, filterEventsVars);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.events);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.events);
});
listStaff
You can execute the listStaff 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:
listStaff(): QueryPromise<ListStaffData, undefined>;
interface ListStaffRef {
...
/* Allow users to create refs without passing in DataConnect */
(): QueryRef<ListStaffData, undefined>;
}
export const listStaffRef: ListStaffRef;
You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
listStaff(dc: DataConnect): QueryPromise<ListStaffData, undefined>;
interface ListStaffRef {
...
(dc: DataConnect): QueryRef<ListStaffData, undefined>;
}
export const listStaffRef: ListStaffRef;
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 listStaffRef:
const name = listStaffRef.operationName;
console.log(name);
Variables
The listStaff query has no variables.
Return Type
Recall that executing the listStaff query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type ListStaffData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface ListStaffData {
staffs: ({
id: UUIDString;
employeeName: string;
vendorId?: UUIDString | null;
email?: string | null;
position?: string | null;
employmentType: EmploymentType;
rating?: number | null;
reliabilityScore?: number | null;
backgroundCheckStatus: BackgroundCheckStatus;
certifications?: string | null;
} & Staff_Key)[];
}
Using listStaff's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, listStaff } from '@dataconnect/generated';
// Call the `listStaff()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await listStaff();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await listStaff(dataConnect);
console.log(data.staffs);
// Or, you can use the `Promise` API.
listStaff().then((response) => {
const data = response.data;
console.log(data.staffs);
});
Using listStaff's QueryRef function
import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, listStaffRef } from '@dataconnect/generated';
// Call the `listStaffRef()` function to get a reference to the query.
const ref = listStaffRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = listStaffRef(dataConnect);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.staffs);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.staffs);
});
Mutations
There are two ways to execute a Data Connect Mutation using the generated Web SDK:
- Using a Mutation Reference function, which returns a
MutationRef- The
MutationRefcan be used as an argument toexecuteMutation(), which will execute the Mutation and return aMutationPromise
- The
- Using an action shortcut function, which returns a
MutationPromise- Calling the action shortcut function will execute the Mutation and return a
MutationPromise
- Calling the action shortcut function will execute the Mutation and return a
The following is true for both the action shortcut function and the MutationRef function:
- The
MutationPromisereturned will resolve to the result of the Mutation once it has finished executing - If the Mutation accepts arguments, both the action shortcut function and the
MutationReffunction accept a single argument: an object that contains all the required variables (and the optional variables) for the Mutation - Both functions can be called with or without passing in a
DataConnectinstance as an argument. If noDataConnectargument is passed in, then the generated SDK will callgetDataConnect(connectorConfig)behind the scenes for you.
Below are examples of how to use the krow-connector connector's generated functions to execute each mutation. You can also follow the examples from the Data Connect documentation.
CreateVendor
You can execute the CreateVendor 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:
createVendor(vars: CreateVendorVariables): MutationPromise<CreateVendorData, CreateVendorVariables>;
interface CreateVendorRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: CreateVendorVariables): MutationRef<CreateVendorData, CreateVendorVariables>;
}
export const createVendorRef: CreateVendorRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
createVendor(dc: DataConnect, vars: CreateVendorVariables): MutationPromise<CreateVendorData, CreateVendorVariables>;
interface CreateVendorRef {
...
(dc: DataConnect, vars: CreateVendorVariables): MutationRef<CreateVendorData, CreateVendorVariables>;
}
export const createVendorRef: CreateVendorRef;
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 createVendorRef:
const name = createVendorRef.operationName;
console.log(name);
Variables
The CreateVendor mutation requires an argument of type CreateVendorVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateVendorVariables {
vendorNumber: string;
legalName: string;
region: VendorRegion;
platformType: VendorPlatformType;
primaryContactEmail: string;
approvalStatus: VendorApprovalStatus;
isActive?: boolean | null;
}
Return Type
Recall that executing the CreateVendor mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type CreateVendorData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateVendorData {
vendor_insert: Vendor_Key;
}
Using CreateVendor's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, createVendor, CreateVendorVariables } from '@dataconnect/generated';
// The `CreateVendor` mutation requires an argument of type `CreateVendorVariables`:
const createVendorVars: CreateVendorVariables = {
vendorNumber: ...,
legalName: ...,
region: ...,
platformType: ...,
primaryContactEmail: ...,
approvalStatus: ...,
isActive: ..., // optional
};
// Call the `createVendor()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await createVendor(createVendorVars);
// Variables can be defined inline as well.
const { data } = await createVendor({ vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await createVendor(dataConnect, createVendorVars);
console.log(data.vendor_insert);
// Or, you can use the `Promise` API.
createVendor(createVendorVars).then((response) => {
const data = response.data;
console.log(data.vendor_insert);
});
Using CreateVendor's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, createVendorRef, CreateVendorVariables } from '@dataconnect/generated';
// The `CreateVendor` mutation requires an argument of type `CreateVendorVariables`:
const createVendorVars: CreateVendorVariables = {
vendorNumber: ...,
legalName: ...,
region: ...,
platformType: ...,
primaryContactEmail: ...,
approvalStatus: ...,
isActive: ..., // optional
};
// Call the `createVendorRef()` function to get a reference to the mutation.
const ref = createVendorRef(createVendorVars);
// Variables can be defined inline as well.
const ref = createVendorRef({ vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = createVendorRef(dataConnect, createVendorVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.vendor_insert);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.vendor_insert);
});
UpdateVendor
You can execute the UpdateVendor 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:
updateVendor(vars: UpdateVendorVariables): MutationPromise<UpdateVendorData, UpdateVendorVariables>;
interface UpdateVendorRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: UpdateVendorVariables): MutationRef<UpdateVendorData, UpdateVendorVariables>;
}
export const updateVendorRef: UpdateVendorRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
updateVendor(dc: DataConnect, vars: UpdateVendorVariables): MutationPromise<UpdateVendorData, UpdateVendorVariables>;
interface UpdateVendorRef {
...
(dc: DataConnect, vars: UpdateVendorVariables): MutationRef<UpdateVendorData, UpdateVendorVariables>;
}
export const updateVendorRef: UpdateVendorRef;
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 updateVendorRef:
const name = updateVendorRef.operationName;
console.log(name);
Variables
The UpdateVendor mutation requires an argument of type UpdateVendorVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface UpdateVendorVariables {
id: UUIDString;
vendorNumber?: string | null;
legalName?: string | null;
region?: VendorRegion | null;
platformType?: VendorPlatformType | null;
primaryContactEmail?: string | null;
approvalStatus?: VendorApprovalStatus | null;
isActive?: boolean | null;
}
Return Type
Recall that executing the UpdateVendor mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type UpdateVendorData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface UpdateVendorData {
vendor_update?: Vendor_Key | null;
}
Using UpdateVendor's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, updateVendor, UpdateVendorVariables } from '@dataconnect/generated';
// The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`:
const updateVendorVars: UpdateVendorVariables = {
id: ...,
vendorNumber: ..., // optional
legalName: ..., // optional
region: ..., // optional
platformType: ..., // optional
primaryContactEmail: ..., // optional
approvalStatus: ..., // optional
isActive: ..., // optional
};
// Call the `updateVendor()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await updateVendor(updateVendorVars);
// Variables can be defined inline as well.
const { data } = await updateVendor({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await updateVendor(dataConnect, updateVendorVars);
console.log(data.vendor_update);
// Or, you can use the `Promise` API.
updateVendor(updateVendorVars).then((response) => {
const data = response.data;
console.log(data.vendor_update);
});
Using UpdateVendor's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, updateVendorRef, UpdateVendorVariables } from '@dataconnect/generated';
// The `UpdateVendor` mutation requires an argument of type `UpdateVendorVariables`:
const updateVendorVars: UpdateVendorVariables = {
id: ...,
vendorNumber: ..., // optional
legalName: ..., // optional
region: ..., // optional
platformType: ..., // optional
primaryContactEmail: ..., // optional
approvalStatus: ..., // optional
isActive: ..., // optional
};
// Call the `updateVendorRef()` function to get a reference to the mutation.
const ref = updateVendorRef(updateVendorVars);
// Variables can be defined inline as well.
const ref = updateVendorRef({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = updateVendorRef(dataConnect, updateVendorVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.vendor_update);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.vendor_update);
});
DeleteVendor
You can execute the DeleteVendor 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:
deleteVendor(vars: DeleteVendorVariables): MutationPromise<DeleteVendorData, DeleteVendorVariables>;
interface DeleteVendorRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: DeleteVendorVariables): MutationRef<DeleteVendorData, DeleteVendorVariables>;
}
export const deleteVendorRef: DeleteVendorRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
deleteVendor(dc: DataConnect, vars: DeleteVendorVariables): MutationPromise<DeleteVendorData, DeleteVendorVariables>;
interface DeleteVendorRef {
...
(dc: DataConnect, vars: DeleteVendorVariables): MutationRef<DeleteVendorData, DeleteVendorVariables>;
}
export const deleteVendorRef: DeleteVendorRef;
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 deleteVendorRef:
const name = deleteVendorRef.operationName;
console.log(name);
Variables
The DeleteVendor mutation requires an argument of type DeleteVendorVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface DeleteVendorVariables {
id: UUIDString;
}
Return Type
Recall that executing the DeleteVendor mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type DeleteVendorData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface DeleteVendorData {
vendor_delete?: Vendor_Key | null;
}
Using DeleteVendor's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, deleteVendor, DeleteVendorVariables } from '@dataconnect/generated';
// The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`:
const deleteVendorVars: DeleteVendorVariables = {
id: ...,
};
// Call the `deleteVendor()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await deleteVendor(deleteVendorVars);
// Variables can be defined inline as well.
const { data } = await deleteVendor({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await deleteVendor(dataConnect, deleteVendorVars);
console.log(data.vendor_delete);
// Or, you can use the `Promise` API.
deleteVendor(deleteVendorVars).then((response) => {
const data = response.data;
console.log(data.vendor_delete);
});
Using DeleteVendor's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, deleteVendorRef, DeleteVendorVariables } from '@dataconnect/generated';
// The `DeleteVendor` mutation requires an argument of type `DeleteVendorVariables`:
const deleteVendorVars: DeleteVendorVariables = {
id: ...,
};
// Call the `deleteVendorRef()` function to get a reference to the mutation.
const ref = deleteVendorRef(deleteVendorVars);
// Variables can be defined inline as well.
const ref = deleteVendorRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = deleteVendorRef(dataConnect, deleteVendorVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.vendor_delete);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.vendor_delete);
});
CreateVendorRate
You can execute the CreateVendorRate 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:
createVendorRate(vars: CreateVendorRateVariables): MutationPromise<CreateVendorRateData, CreateVendorRateVariables>;
interface CreateVendorRateRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: CreateVendorRateVariables): MutationRef<CreateVendorRateData, CreateVendorRateVariables>;
}
export const createVendorRateRef: CreateVendorRateRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
createVendorRate(dc: DataConnect, vars: CreateVendorRateVariables): MutationPromise<CreateVendorRateData, CreateVendorRateVariables>;
interface CreateVendorRateRef {
...
(dc: DataConnect, vars: CreateVendorRateVariables): MutationRef<CreateVendorRateData, CreateVendorRateVariables>;
}
export const createVendorRateRef: CreateVendorRateRef;
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 createVendorRateRef:
const name = createVendorRateRef.operationName;
console.log(name);
Variables
The CreateVendorRate mutation requires an argument of type CreateVendorRateVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateVendorRateVariables {
vendorName: string;
category: VendorRateCategory;
roleName: string;
employeeWage: number;
markupPercentage?: number | null;
vendorFeePercentage?: number | null;
clientRate: number;
}
Return Type
Recall that executing the CreateVendorRate mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type CreateVendorRateData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateVendorRateData {
vendorRate_insert: VendorRate_Key;
}
Using CreateVendorRate's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, createVendorRate, CreateVendorRateVariables } from '@dataconnect/generated';
// The `CreateVendorRate` mutation requires an argument of type `CreateVendorRateVariables`:
const createVendorRateVars: CreateVendorRateVariables = {
vendorName: ...,
category: ...,
roleName: ...,
employeeWage: ...,
markupPercentage: ..., // optional
vendorFeePercentage: ..., // optional
clientRate: ...,
};
// Call the `createVendorRate()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await createVendorRate(createVendorRateVars);
// Variables can be defined inline as well.
const { data } = await createVendorRate({ vendorName: ..., category: ..., roleName: ..., employeeWage: ..., markupPercentage: ..., vendorFeePercentage: ..., clientRate: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await createVendorRate(dataConnect, createVendorRateVars);
console.log(data.vendorRate_insert);
// Or, you can use the `Promise` API.
createVendorRate(createVendorRateVars).then((response) => {
const data = response.data;
console.log(data.vendorRate_insert);
});
Using CreateVendorRate's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, createVendorRateRef, CreateVendorRateVariables } from '@dataconnect/generated';
// The `CreateVendorRate` mutation requires an argument of type `CreateVendorRateVariables`:
const createVendorRateVars: CreateVendorRateVariables = {
vendorName: ...,
category: ...,
roleName: ...,
employeeWage: ...,
markupPercentage: ..., // optional
vendorFeePercentage: ..., // optional
clientRate: ...,
};
// Call the `createVendorRateRef()` function to get a reference to the mutation.
const ref = createVendorRateRef(createVendorRateVars);
// Variables can be defined inline as well.
const ref = createVendorRateRef({ vendorName: ..., category: ..., roleName: ..., employeeWage: ..., markupPercentage: ..., vendorFeePercentage: ..., clientRate: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = createVendorRateRef(dataConnect, createVendorRateVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.vendorRate_insert);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.vendorRate_insert);
});
UpdateVendorRate
You can execute the UpdateVendorRate 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:
updateVendorRate(vars: UpdateVendorRateVariables): MutationPromise<UpdateVendorRateData, UpdateVendorRateVariables>;
interface UpdateVendorRateRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: UpdateVendorRateVariables): MutationRef<UpdateVendorRateData, UpdateVendorRateVariables>;
}
export const updateVendorRateRef: UpdateVendorRateRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
updateVendorRate(dc: DataConnect, vars: UpdateVendorRateVariables): MutationPromise<UpdateVendorRateData, UpdateVendorRateVariables>;
interface UpdateVendorRateRef {
...
(dc: DataConnect, vars: UpdateVendorRateVariables): MutationRef<UpdateVendorRateData, UpdateVendorRateVariables>;
}
export const updateVendorRateRef: UpdateVendorRateRef;
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 updateVendorRateRef:
const name = updateVendorRateRef.operationName;
console.log(name);
Variables
The UpdateVendorRate mutation requires an argument of type UpdateVendorRateVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface UpdateVendorRateVariables {
id: UUIDString;
vendorName?: string | null;
category?: VendorRateCategory | null;
roleName?: string | null;
employeeWage?: number | null;
markupPercentage?: number | null;
vendorFeePercentage?: number | null;
clientRate?: number | null;
}
Return Type
Recall that executing the UpdateVendorRate mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type UpdateVendorRateData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface UpdateVendorRateData {
vendorRate_update?: VendorRate_Key | null;
}
Using UpdateVendorRate's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, updateVendorRate, UpdateVendorRateVariables } from '@dataconnect/generated';
// The `UpdateVendorRate` mutation requires an argument of type `UpdateVendorRateVariables`:
const updateVendorRateVars: UpdateVendorRateVariables = {
id: ...,
vendorName: ..., // optional
category: ..., // optional
roleName: ..., // optional
employeeWage: ..., // optional
markupPercentage: ..., // optional
vendorFeePercentage: ..., // optional
clientRate: ..., // optional
};
// Call the `updateVendorRate()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await updateVendorRate(updateVendorRateVars);
// Variables can be defined inline as well.
const { data } = await updateVendorRate({ id: ..., vendorName: ..., category: ..., roleName: ..., employeeWage: ..., markupPercentage: ..., vendorFeePercentage: ..., clientRate: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await updateVendorRate(dataConnect, updateVendorRateVars);
console.log(data.vendorRate_update);
// Or, you can use the `Promise` API.
updateVendorRate(updateVendorRateVars).then((response) => {
const data = response.data;
console.log(data.vendorRate_update);
});
Using UpdateVendorRate's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, updateVendorRateRef, UpdateVendorRateVariables } from '@dataconnect/generated';
// The `UpdateVendorRate` mutation requires an argument of type `UpdateVendorRateVariables`:
const updateVendorRateVars: UpdateVendorRateVariables = {
id: ...,
vendorName: ..., // optional
category: ..., // optional
roleName: ..., // optional
employeeWage: ..., // optional
markupPercentage: ..., // optional
vendorFeePercentage: ..., // optional
clientRate: ..., // optional
};
// Call the `updateVendorRateRef()` function to get a reference to the mutation.
const ref = updateVendorRateRef(updateVendorRateVars);
// Variables can be defined inline as well.
const ref = updateVendorRateRef({ id: ..., vendorName: ..., category: ..., roleName: ..., employeeWage: ..., markupPercentage: ..., vendorFeePercentage: ..., clientRate: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = updateVendorRateRef(dataConnect, updateVendorRateVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.vendorRate_update);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.vendorRate_update);
});
DeleteVendorRate
You can execute the DeleteVendorRate 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:
deleteVendorRate(vars: DeleteVendorRateVariables): MutationPromise<DeleteVendorRateData, DeleteVendorRateVariables>;
interface DeleteVendorRateRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: DeleteVendorRateVariables): MutationRef<DeleteVendorRateData, DeleteVendorRateVariables>;
}
export const deleteVendorRateRef: DeleteVendorRateRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
deleteVendorRate(dc: DataConnect, vars: DeleteVendorRateVariables): MutationPromise<DeleteVendorRateData, DeleteVendorRateVariables>;
interface DeleteVendorRateRef {
...
(dc: DataConnect, vars: DeleteVendorRateVariables): MutationRef<DeleteVendorRateData, DeleteVendorRateVariables>;
}
export const deleteVendorRateRef: DeleteVendorRateRef;
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 deleteVendorRateRef:
const name = deleteVendorRateRef.operationName;
console.log(name);
Variables
The DeleteVendorRate mutation requires an argument of type DeleteVendorRateVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface DeleteVendorRateVariables {
id: UUIDString;
}
Return Type
Recall that executing the DeleteVendorRate mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type DeleteVendorRateData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface DeleteVendorRateData {
vendorRate_delete?: VendorRate_Key | null;
}
Using DeleteVendorRate's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, deleteVendorRate, DeleteVendorRateVariables } from '@dataconnect/generated';
// The `DeleteVendorRate` mutation requires an argument of type `DeleteVendorRateVariables`:
const deleteVendorRateVars: DeleteVendorRateVariables = {
id: ...,
};
// Call the `deleteVendorRate()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await deleteVendorRate(deleteVendorRateVars);
// Variables can be defined inline as well.
const { data } = await deleteVendorRate({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await deleteVendorRate(dataConnect, deleteVendorRateVars);
console.log(data.vendorRate_delete);
// Or, you can use the `Promise` API.
deleteVendorRate(deleteVendorRateVars).then((response) => {
const data = response.data;
console.log(data.vendorRate_delete);
});
Using DeleteVendorRate's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, deleteVendorRateRef, DeleteVendorRateVariables } from '@dataconnect/generated';
// The `DeleteVendorRate` mutation requires an argument of type `DeleteVendorRateVariables`:
const deleteVendorRateVars: DeleteVendorRateVariables = {
id: ...,
};
// Call the `deleteVendorRateRef()` function to get a reference to the mutation.
const ref = deleteVendorRateRef(deleteVendorRateVars);
// Variables can be defined inline as well.
const ref = deleteVendorRateRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = deleteVendorRateRef(dataConnect, deleteVendorRateVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.vendorRate_delete);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.vendorRate_delete);
});
CreateEvent
You can execute the CreateEvent 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:
createEvent(vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
interface CreateEventRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
}
export const createEventRef: CreateEventRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
interface CreateEventRef {
...
(dc: DataConnect, vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
}
export const createEventRef: CreateEventRef;
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 createEventRef:
const name = createEventRef.operationName;
console.log(name);
Variables
The CreateEvent mutation requires an argument of type CreateEventVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateEventVariables {
eventName: string;
isRapid?: boolean | null;
isRecurring?: boolean | null;
isMultiDay?: boolean | null;
recurrenceType?: RecurrenceType | null;
recurrenceStartDate?: TimestampString | null;
recurrenceEndDate?: TimestampString | null;
scatterDates?: string | null;
multiDayStartDate?: TimestampString | null;
multiDayEndDate?: TimestampString | null;
bufferTimeBefore?: number | null;
bufferTimeAfter?: number | null;
conflictDetectionEnabled?: boolean | null;
detectedConflicts?: string | null;
businessId: UUIDString;
businessName?: string | null;
vendorId?: UUIDString | null;
vendorName?: string | null;
hub?: string | null;
eventLocation?: string | null;
contractType?: ContractType | null;
poReference?: string | null;
status: EventStatus;
date: TimestampString;
shifts?: string | null;
addons?: string | null;
total?: number | null;
clientName?: string | null;
clientEmail?: string | null;
clientPhone?: string | null;
invoiceId?: UUIDString | null;
notes?: string | null;
requested?: number | null;
assignedStaff?: string | null;
}
Return Type
Recall that executing the CreateEvent mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type CreateEventData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateEventData {
event_insert: Event_Key;
}
Using CreateEvent's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, createEvent, CreateEventVariables } from '@dataconnect/generated';
// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`:
const createEventVars: CreateEventVariables = {
eventName: ...,
isRapid: ..., // optional
isRecurring: ..., // optional
isMultiDay: ..., // optional
recurrenceType: ..., // optional
recurrenceStartDate: ..., // optional
recurrenceEndDate: ..., // optional
scatterDates: ..., // optional
multiDayStartDate: ..., // optional
multiDayEndDate: ..., // optional
bufferTimeBefore: ..., // optional
bufferTimeAfter: ..., // optional
conflictDetectionEnabled: ..., // optional
detectedConflicts: ..., // optional
businessId: ...,
businessName: ..., // optional
vendorId: ..., // optional
vendorName: ..., // optional
hub: ..., // optional
eventLocation: ..., // optional
contractType: ..., // optional
poReference: ..., // optional
status: ...,
date: ...,
shifts: ..., // optional
addons: ..., // optional
total: ..., // optional
clientName: ..., // optional
clientEmail: ..., // optional
clientPhone: ..., // optional
invoiceId: ..., // optional
notes: ..., // optional
requested: ..., // optional
assignedStaff: ..., // optional
};
// Call the `createEvent()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await createEvent(createEventVars);
// Variables can be defined inline as well.
const { data } = await createEvent({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await createEvent(dataConnect, createEventVars);
console.log(data.event_insert);
// Or, you can use the `Promise` API.
createEvent(createEventVars).then((response) => {
const data = response.data;
console.log(data.event_insert);
});
Using CreateEvent's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, createEventRef, CreateEventVariables } from '@dataconnect/generated';
// The `CreateEvent` mutation requires an argument of type `CreateEventVariables`:
const createEventVars: CreateEventVariables = {
eventName: ...,
isRapid: ..., // optional
isRecurring: ..., // optional
isMultiDay: ..., // optional
recurrenceType: ..., // optional
recurrenceStartDate: ..., // optional
recurrenceEndDate: ..., // optional
scatterDates: ..., // optional
multiDayStartDate: ..., // optional
multiDayEndDate: ..., // optional
bufferTimeBefore: ..., // optional
bufferTimeAfter: ..., // optional
conflictDetectionEnabled: ..., // optional
detectedConflicts: ..., // optional
businessId: ...,
businessName: ..., // optional
vendorId: ..., // optional
vendorName: ..., // optional
hub: ..., // optional
eventLocation: ..., // optional
contractType: ..., // optional
poReference: ..., // optional
status: ...,
date: ...,
shifts: ..., // optional
addons: ..., // optional
total: ..., // optional
clientName: ..., // optional
clientEmail: ..., // optional
clientPhone: ..., // optional
invoiceId: ..., // optional
notes: ..., // optional
requested: ..., // optional
assignedStaff: ..., // optional
};
// Call the `createEventRef()` function to get a reference to the mutation.
const ref = createEventRef(createEventVars);
// Variables can be defined inline as well.
const ref = createEventRef({ eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = createEventRef(dataConnect, createEventVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.event_insert);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.event_insert);
});
UpdateEvent
You can execute the UpdateEvent 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:
updateEvent(vars: UpdateEventVariables): MutationPromise<UpdateEventData, UpdateEventVariables>;
interface UpdateEventRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: UpdateEventVariables): MutationRef<UpdateEventData, UpdateEventVariables>;
}
export const updateEventRef: UpdateEventRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
updateEvent(dc: DataConnect, vars: UpdateEventVariables): MutationPromise<UpdateEventData, UpdateEventVariables>;
interface UpdateEventRef {
...
(dc: DataConnect, vars: UpdateEventVariables): MutationRef<UpdateEventData, UpdateEventVariables>;
}
export const updateEventRef: UpdateEventRef;
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 updateEventRef:
const name = updateEventRef.operationName;
console.log(name);
Variables
The UpdateEvent mutation requires an argument of type UpdateEventVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface UpdateEventVariables {
id: UUIDString;
eventName?: string | null;
isRapid?: boolean | null;
isRecurring?: boolean | null;
isMultiDay?: boolean | null;
recurrenceType?: RecurrenceType | null;
recurrenceStartDate?: TimestampString | null;
recurrenceEndDate?: TimestampString | null;
scatterDates?: string | null;
multiDayStartDate?: TimestampString | null;
multiDayEndDate?: TimestampString | null;
bufferTimeBefore?: number | null;
bufferTimeAfter?: number | null;
conflictDetectionEnabled?: boolean | null;
detectedConflicts?: string | null;
businessId?: UUIDString | null;
businessName?: string | null;
vendorId?: UUIDString | null;
vendorName?: string | null;
hub?: string | null;
eventLocation?: string | null;
contractType?: ContractType | null;
poReference?: string | null;
status?: EventStatus | null;
date?: TimestampString | null;
shifts?: string | null;
addons?: string | null;
total?: number | null;
clientName?: string | null;
clientEmail?: string | null;
clientPhone?: string | null;
invoiceId?: UUIDString | null;
notes?: string | null;
requested?: number | null;
assignedStaff?: string | null;
}
Return Type
Recall that executing the UpdateEvent mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type UpdateEventData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface UpdateEventData {
event_update?: Event_Key | null;
}
Using UpdateEvent's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, updateEvent, UpdateEventVariables } from '@dataconnect/generated';
// The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`:
const updateEventVars: UpdateEventVariables = {
id: ...,
eventName: ..., // optional
isRapid: ..., // optional
isRecurring: ..., // optional
isMultiDay: ..., // optional
recurrenceType: ..., // optional
recurrenceStartDate: ..., // optional
recurrenceEndDate: ..., // optional
scatterDates: ..., // optional
multiDayStartDate: ..., // optional
multiDayEndDate: ..., // optional
bufferTimeBefore: ..., // optional
bufferTimeAfter: ..., // optional
conflictDetectionEnabled: ..., // optional
detectedConflicts: ..., // optional
businessId: ..., // optional
businessName: ..., // optional
vendorId: ..., // optional
vendorName: ..., // optional
hub: ..., // optional
eventLocation: ..., // optional
contractType: ..., // optional
poReference: ..., // optional
status: ..., // optional
date: ..., // optional
shifts: ..., // optional
addons: ..., // optional
total: ..., // optional
clientName: ..., // optional
clientEmail: ..., // optional
clientPhone: ..., // optional
invoiceId: ..., // optional
notes: ..., // optional
requested: ..., // optional
assignedStaff: ..., // optional
};
// Call the `updateEvent()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await updateEvent(updateEventVars);
// Variables can be defined inline as well.
const { data } = await updateEvent({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await updateEvent(dataConnect, updateEventVars);
console.log(data.event_update);
// Or, you can use the `Promise` API.
updateEvent(updateEventVars).then((response) => {
const data = response.data;
console.log(data.event_update);
});
Using UpdateEvent's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, updateEventRef, UpdateEventVariables } from '@dataconnect/generated';
// The `UpdateEvent` mutation requires an argument of type `UpdateEventVariables`:
const updateEventVars: UpdateEventVariables = {
id: ...,
eventName: ..., // optional
isRapid: ..., // optional
isRecurring: ..., // optional
isMultiDay: ..., // optional
recurrenceType: ..., // optional
recurrenceStartDate: ..., // optional
recurrenceEndDate: ..., // optional
scatterDates: ..., // optional
multiDayStartDate: ..., // optional
multiDayEndDate: ..., // optional
bufferTimeBefore: ..., // optional
bufferTimeAfter: ..., // optional
conflictDetectionEnabled: ..., // optional
detectedConflicts: ..., // optional
businessId: ..., // optional
businessName: ..., // optional
vendorId: ..., // optional
vendorName: ..., // optional
hub: ..., // optional
eventLocation: ..., // optional
contractType: ..., // optional
poReference: ..., // optional
status: ..., // optional
date: ..., // optional
shifts: ..., // optional
addons: ..., // optional
total: ..., // optional
clientName: ..., // optional
clientEmail: ..., // optional
clientPhone: ..., // optional
invoiceId: ..., // optional
notes: ..., // optional
requested: ..., // optional
assignedStaff: ..., // optional
};
// Call the `updateEventRef()` function to get a reference to the mutation.
const ref = updateEventRef(updateEventVars);
// Variables can be defined inline as well.
const ref = updateEventRef({ id: ..., eventName: ..., isRapid: ..., isRecurring: ..., isMultiDay: ..., recurrenceType: ..., recurrenceStartDate: ..., recurrenceEndDate: ..., scatterDates: ..., multiDayStartDate: ..., multiDayEndDate: ..., bufferTimeBefore: ..., bufferTimeAfter: ..., conflictDetectionEnabled: ..., detectedConflicts: ..., businessId: ..., businessName: ..., vendorId: ..., vendorName: ..., hub: ..., eventLocation: ..., contractType: ..., poReference: ..., status: ..., date: ..., shifts: ..., addons: ..., total: ..., clientName: ..., clientEmail: ..., clientPhone: ..., invoiceId: ..., notes: ..., requested: ..., assignedStaff: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = updateEventRef(dataConnect, updateEventVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.event_update);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.event_update);
});
DeleteEvent
You can execute the DeleteEvent 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:
deleteEvent(vars: DeleteEventVariables): MutationPromise<DeleteEventData, DeleteEventVariables>;
interface DeleteEventRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: DeleteEventVariables): MutationRef<DeleteEventData, DeleteEventVariables>;
}
export const deleteEventRef: DeleteEventRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
deleteEvent(dc: DataConnect, vars: DeleteEventVariables): MutationPromise<DeleteEventData, DeleteEventVariables>;
interface DeleteEventRef {
...
(dc: DataConnect, vars: DeleteEventVariables): MutationRef<DeleteEventData, DeleteEventVariables>;
}
export const deleteEventRef: DeleteEventRef;
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 deleteEventRef:
const name = deleteEventRef.operationName;
console.log(name);
Variables
The DeleteEvent mutation requires an argument of type DeleteEventVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface DeleteEventVariables {
id: UUIDString;
}
Return Type
Recall that executing the DeleteEvent mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type DeleteEventData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface DeleteEventData {
event_delete?: Event_Key | null;
}
Using DeleteEvent's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, deleteEvent, DeleteEventVariables } from '@dataconnect/generated';
// The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`:
const deleteEventVars: DeleteEventVariables = {
id: ...,
};
// Call the `deleteEvent()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await deleteEvent(deleteEventVars);
// Variables can be defined inline as well.
const { data } = await deleteEvent({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await deleteEvent(dataConnect, deleteEventVars);
console.log(data.event_delete);
// Or, you can use the `Promise` API.
deleteEvent(deleteEventVars).then((response) => {
const data = response.data;
console.log(data.event_delete);
});
Using DeleteEvent's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, deleteEventRef, DeleteEventVariables } from '@dataconnect/generated';
// The `DeleteEvent` mutation requires an argument of type `DeleteEventVariables`:
const deleteEventVars: DeleteEventVariables = {
id: ...,
};
// Call the `deleteEventRef()` function to get a reference to the mutation.
const ref = deleteEventRef(deleteEventVars);
// Variables can be defined inline as well.
const ref = deleteEventRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = deleteEventRef(dataConnect, deleteEventVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.event_delete);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.event_delete);
});
CreateStaff
You can execute the CreateStaff 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:
createStaff(vars: CreateStaffVariables): MutationPromise<CreateStaffData, CreateStaffVariables>;
interface CreateStaffRef {
...
/* Allow users to create refs without passing in DataConnect */
(vars: CreateStaffVariables): MutationRef<CreateStaffData, CreateStaffVariables>;
}
export const createStaffRef: CreateStaffRef;
You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
createStaff(dc: DataConnect, vars: CreateStaffVariables): MutationPromise<CreateStaffData, CreateStaffVariables>;
interface CreateStaffRef {
...
(dc: DataConnect, vars: CreateStaffVariables): MutationRef<CreateStaffData, CreateStaffVariables>;
}
export const createStaffRef: CreateStaffRef;
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 createStaffRef:
const name = createStaffRef.operationName;
console.log(name);
Variables
The CreateStaff mutation requires an argument of type CreateStaffVariables, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateStaffVariables {
employeeName: string;
vendorId?: UUIDString | null;
email?: string | null;
position?: string | null;
employmentType: EmploymentType;
rating?: number | null;
reliabilityScore?: number | null;
backgroundCheckStatus: BackgroundCheckStatus;
certifications?: string | null;
}
Return Type
Recall that executing the CreateStaff mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type CreateStaffData, which is defined in dataconnect-generated/index.d.ts. It has the following fields:
export interface CreateStaffData {
staff_insert: Staff_Key;
}
Using CreateStaff's action shortcut function
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, createStaff, CreateStaffVariables } from '@dataconnect/generated';
// The `CreateStaff` mutation requires an argument of type `CreateStaffVariables`:
const createStaffVars: CreateStaffVariables = {
employeeName: ...,
vendorId: ..., // optional
email: ..., // optional
position: ..., // optional
employmentType: ...,
rating: ..., // optional
reliabilityScore: ..., // optional
backgroundCheckStatus: ...,
certifications: ..., // optional
};
// Call the `createStaff()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await createStaff(createStaffVars);
// Variables can be defined inline as well.
const { data } = await createStaff({ employeeName: ..., vendorId: ..., email: ..., position: ..., employmentType: ..., rating: ..., reliabilityScore: ..., backgroundCheckStatus: ..., certifications: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await createStaff(dataConnect, createStaffVars);
console.log(data.staff_insert);
// Or, you can use the `Promise` API.
createStaff(createStaffVars).then((response) => {
const data = response.data;
console.log(data.staff_insert);
});
Using CreateStaff's MutationRef function
import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, createStaffRef, CreateStaffVariables } from '@dataconnect/generated';
// The `CreateStaff` mutation requires an argument of type `CreateStaffVariables`:
const createStaffVars: CreateStaffVariables = {
employeeName: ...,
vendorId: ..., // optional
email: ..., // optional
position: ..., // optional
employmentType: ...,
rating: ..., // optional
reliabilityScore: ..., // optional
backgroundCheckStatus: ...,
certifications: ..., // optional
};
// Call the `createStaffRef()` function to get a reference to the mutation.
const ref = createStaffRef(createStaffVars);
// Variables can be defined inline as well.
const ref = createStaffRef({ employeeName: ..., vendorId: ..., email: ..., position: ..., employmentType: ..., rating: ..., reliabilityScore: ..., backgroundCheckStatus: ..., certifications: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = createStaffRef(dataConnect, createStaffVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.staff_insert);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.staff_insert);
});