Merge pull request #74 from Oloodi/73-backend-extend-vendor-entity-implement-get-update-delete-filter-operations
73 backend extend vendor entity implement get update delete filter operations
This commit is contained in:
31
dataconnect/connector/vendor/mutations.gql
vendored
31
dataconnect/connector/vendor/mutations.gql
vendored
@@ -19,3 +19,34 @@ mutation CreateVendor(
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
mutation UpdateVendor(
|
||||
$id: UUID!,
|
||||
$vendorNumber: String,
|
||||
$legalName: String,
|
||||
$region: VendorRegion,
|
||||
$platformType: VendorPlatformType,
|
||||
$primaryContactEmail: String,
|
||||
$approvalStatus: VendorApprovalStatus,
|
||||
$isActive: Boolean
|
||||
) @auth(level: USER) {
|
||||
vendor_update(
|
||||
id: $id,
|
||||
data: {
|
||||
vendorNumber: $vendorNumber
|
||||
legalName: $legalName
|
||||
region: $region
|
||||
platformType: $platformType
|
||||
primaryContactEmail: $primaryContactEmail
|
||||
approvalStatus: $approvalStatus
|
||||
isActive: $isActive
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
mutation DeleteVendor(
|
||||
$id: UUID!
|
||||
) @auth(level: USER) {
|
||||
vendor_delete(id: $id)
|
||||
}
|
||||
|
||||
|
||||
45
dataconnect/connector/vendor/queries.gql
vendored
45
dataconnect/connector/vendor/queries.gql
vendored
@@ -10,3 +10,48 @@ query listVendor @auth(level: USER) {
|
||||
isActive
|
||||
}
|
||||
}
|
||||
|
||||
query getVendorById(
|
||||
$id: UUID!
|
||||
) @auth(level: USER) {
|
||||
vendor(id: $id) {
|
||||
id
|
||||
vendorNumber
|
||||
legalName
|
||||
region
|
||||
platformType
|
||||
primaryContactEmail
|
||||
approvalStatus
|
||||
isActive
|
||||
}
|
||||
}
|
||||
|
||||
query filterVendors(
|
||||
$region: VendorRegion,
|
||||
$approvalStatus: VendorApprovalStatus,
|
||||
$isActive: Boolean,
|
||||
$vendorNumber:String,
|
||||
$primaryContactEmail:String,
|
||||
$legalName: String,
|
||||
$platformType: VendorPlatformType
|
||||
) @auth(level: USER) {
|
||||
vendors(where:{
|
||||
region: { eq: $region }
|
||||
approvalStatus: { eq: $approvalStatus }
|
||||
isActive: { eq: $isActive }
|
||||
vendorNumber: { eq: $vendorNumber }
|
||||
primaryContactEmail: { eq: $primaryContactEmail }
|
||||
legalName: { eq: $legalName }
|
||||
platformType: { eq: $platformType }
|
||||
|
||||
}) {
|
||||
id
|
||||
vendorNumber
|
||||
legalName
|
||||
region
|
||||
platformType
|
||||
primaryContactEmail
|
||||
approvalStatus
|
||||
isActive
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,9 @@ For each operation, there is a wrapper hook that can be used to call the operati
|
||||
|
||||
Here are all of the hooks that get generated:
|
||||
```ts
|
||||
import { useListVendor, useCreateEvent, useListEvents, useCreateStaff, useListStaff, useCreateVendor } from '@dataconnect/generated/react';
|
||||
import { useListEvents, useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent } from '@dataconnect/generated/react';
|
||||
// The types of these hooks are available in react/index.d.ts
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useListVendor();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useListEvents();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateStaff(createStaffVars);
|
||||
@@ -27,6 +23,18 @@ const { data, isPending, isSuccess, isError, error } = useListStaff();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateVendor(createVendorVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useUpdateVendor(updateVendorVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useDeleteVendor(deleteVendorVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useListVendor();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useGetVendorById(getVendorByIdVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useFilterVendors(filterVendorsVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars);
|
||||
|
||||
```
|
||||
|
||||
Here's an example from a different generated SDK:
|
||||
@@ -64,15 +72,9 @@ If a user is not using a supported framework, they can use the generated SDK dir
|
||||
Here's an example of how to use it with the first 5 operations:
|
||||
|
||||
```js
|
||||
import { listVendor, createEvent, listEvents, createStaff, listStaff, createVendor } from '@dataconnect/generated';
|
||||
import { listEvents, createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent } from '@dataconnect/generated';
|
||||
|
||||
|
||||
// Operation listVendor:
|
||||
const { data } = await ListVendor(dataConnect);
|
||||
|
||||
// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts
|
||||
const { data } = await CreateEvent(dataConnect, createEventVars);
|
||||
|
||||
// Operation listEvents:
|
||||
const { data } = await ListEvents(dataConnect);
|
||||
|
||||
@@ -85,5 +87,23 @@ const { data } = await ListStaff(dataConnect);
|
||||
// Operation CreateVendor: For variables, look at type CreateVendorVars in ../index.d.ts
|
||||
const { data } = await CreateVendor(dataConnect, createVendorVars);
|
||||
|
||||
// Operation UpdateVendor: For variables, look at type UpdateVendorVars in ../index.d.ts
|
||||
const { data } = await UpdateVendor(dataConnect, updateVendorVars);
|
||||
|
||||
// Operation DeleteVendor: For variables, look at type DeleteVendorVars in ../index.d.ts
|
||||
const { data } = await DeleteVendor(dataConnect, deleteVendorVars);
|
||||
|
||||
// Operation listVendor:
|
||||
const { data } = await ListVendor(dataConnect);
|
||||
|
||||
// Operation getVendorById: For variables, look at type GetVendorByIdVars in ../index.d.ts
|
||||
const { data } = await GetVendorById(dataConnect, getVendorByIdVars);
|
||||
|
||||
// Operation filterVendors: For variables, look at type FilterVendorsVars in ../index.d.ts
|
||||
const { data } = await FilterVendors(dataConnect, filterVendorsVars);
|
||||
|
||||
// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts
|
||||
const { data } = await CreateEvent(dataConnect, createEventVars);
|
||||
|
||||
|
||||
```
|
||||
File diff suppressed because it is too large
Load Diff
@@ -61,28 +61,6 @@ export const connectorConfig = {
|
||||
location: 'us-central1'
|
||||
};
|
||||
|
||||
export const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
|
||||
export function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
}
|
||||
|
||||
export const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
|
||||
export function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const listEventsRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
@@ -127,3 +105,69 @@ export function createVendor(dcOrVars, vars) {
|
||||
return executeMutation(createVendorRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const updateVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'UpdateVendor', inputVars);
|
||||
}
|
||||
updateVendorRef.operationName = 'UpdateVendor';
|
||||
|
||||
export function updateVendor(dcOrVars, vars) {
|
||||
return executeMutation(updateVendorRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const deleteVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'DeleteVendor', inputVars);
|
||||
}
|
||||
deleteVendorRef.operationName = 'DeleteVendor';
|
||||
|
||||
export function deleteVendor(dcOrVars, vars) {
|
||||
return executeMutation(deleteVendorRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
|
||||
export function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
}
|
||||
|
||||
export const getVendorByIdRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'getVendorById', inputVars);
|
||||
}
|
||||
getVendorByIdRef.operationName = 'getVendorById';
|
||||
|
||||
export function getVendorById(dcOrVars, vars) {
|
||||
return executeQuery(getVendorByIdRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const filterVendorsRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'filterVendors', inputVars);
|
||||
}
|
||||
filterVendorsRef.operationName = 'filterVendors';
|
||||
|
||||
export function filterVendors(dcOrVars, vars) {
|
||||
return executeQuery(filterVendorsRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
|
||||
export function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
|
||||
@@ -69,30 +69,6 @@ const connectorConfig = {
|
||||
};
|
||||
exports.connectorConfig = connectorConfig;
|
||||
|
||||
const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
exports.listVendorRef = listVendorRef;
|
||||
|
||||
exports.listVendor = function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
};
|
||||
|
||||
const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
exports.createEventRef = createEventRef;
|
||||
|
||||
exports.createEvent = function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const listEventsRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
@@ -140,3 +116,75 @@ exports.createVendorRef = createVendorRef;
|
||||
exports.createVendor = function createVendor(dcOrVars, vars) {
|
||||
return executeMutation(createVendorRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const updateVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'UpdateVendor', inputVars);
|
||||
}
|
||||
updateVendorRef.operationName = 'UpdateVendor';
|
||||
exports.updateVendorRef = updateVendorRef;
|
||||
|
||||
exports.updateVendor = function updateVendor(dcOrVars, vars) {
|
||||
return executeMutation(updateVendorRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const deleteVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'DeleteVendor', inputVars);
|
||||
}
|
||||
deleteVendorRef.operationName = 'DeleteVendor';
|
||||
exports.deleteVendorRef = deleteVendorRef;
|
||||
|
||||
exports.deleteVendor = function deleteVendor(dcOrVars, vars) {
|
||||
return executeMutation(deleteVendorRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
exports.listVendorRef = listVendorRef;
|
||||
|
||||
exports.listVendor = function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
};
|
||||
|
||||
const getVendorByIdRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'getVendorById', inputVars);
|
||||
}
|
||||
getVendorByIdRef.operationName = 'getVendorById';
|
||||
exports.getVendorByIdRef = getVendorByIdRef;
|
||||
|
||||
exports.getVendorById = function getVendorById(dcOrVars, vars) {
|
||||
return executeQuery(getVendorByIdRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const filterVendorsRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'filterVendors', inputVars);
|
||||
}
|
||||
filterVendorsRef.operationName = 'filterVendors';
|
||||
exports.filterVendorsRef = filterVendorsRef;
|
||||
|
||||
exports.filterVendors = function filterVendors(dcOrVars, vars) {
|
||||
return executeQuery(filterVendorsRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
exports.createEventRef = createEventRef;
|
||||
|
||||
exports.createEvent = function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
159
frontend-web/src/dataconnect-generated/index.d.ts
vendored
159
frontend-web/src/dataconnect-generated/index.d.ts
vendored
@@ -113,11 +113,59 @@ export interface CreateVendorVariables {
|
||||
isActive?: boolean | null;
|
||||
}
|
||||
|
||||
export interface DeleteVendorData {
|
||||
vendor_delete?: Vendor_Key | null;
|
||||
}
|
||||
|
||||
export interface DeleteVendorVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
|
||||
export interface Event_Key {
|
||||
id: UUIDString;
|
||||
__typename?: 'Event_Key';
|
||||
}
|
||||
|
||||
export interface FilterVendorsData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
|
||||
export interface FilterVendorsVariables {
|
||||
region?: VendorRegion | null;
|
||||
approvalStatus?: VendorApprovalStatus | null;
|
||||
isActive?: boolean | null;
|
||||
vendorNumber?: string | null;
|
||||
primaryContactEmail?: string | null;
|
||||
legalName?: string | null;
|
||||
platformType?: VendorPlatformType | null;
|
||||
}
|
||||
|
||||
export interface GetVendorByIdData {
|
||||
vendor?: {
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key;
|
||||
}
|
||||
|
||||
export interface GetVendorByIdVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
|
||||
export interface ListEventsData {
|
||||
events: ({
|
||||
id: UUIDString;
|
||||
@@ -166,35 +214,26 @@ export interface Staff_Key {
|
||||
__typename?: 'Staff_Key';
|
||||
}
|
||||
|
||||
export interface UpdateVendorData {
|
||||
vendor_update?: Vendor_Key | null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export interface Vendor_Key {
|
||||
id: UUIDString;
|
||||
__typename?: 'Vendor_Key';
|
||||
}
|
||||
|
||||
interface ListVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(): QueryRef<ListVendorData, undefined>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect): QueryRef<ListVendorData, undefined>;
|
||||
operationName: string;
|
||||
}
|
||||
export const listVendorRef: ListVendorRef;
|
||||
|
||||
export function listVendor(): QueryPromise<ListVendorData, undefined>;
|
||||
export function listVendor(dc: DataConnect): QueryPromise<ListVendorData, undefined>;
|
||||
|
||||
interface CreateEventRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const createEventRef: CreateEventRef;
|
||||
|
||||
export function createEvent(vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
|
||||
interface ListEventsRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(): QueryRef<ListEventsData, undefined>;
|
||||
@@ -243,3 +282,75 @@ export const createVendorRef: CreateVendorRef;
|
||||
export function createVendor(vars: CreateVendorVariables): MutationPromise<CreateVendorData, CreateVendorVariables>;
|
||||
export function createVendor(dc: DataConnect, vars: CreateVendorVariables): MutationPromise<CreateVendorData, CreateVendorVariables>;
|
||||
|
||||
interface UpdateVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: UpdateVendorVariables): MutationRef<UpdateVendorData, UpdateVendorVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: UpdateVendorVariables): MutationRef<UpdateVendorData, UpdateVendorVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const updateVendorRef: UpdateVendorRef;
|
||||
|
||||
export function updateVendor(vars: UpdateVendorVariables): MutationPromise<UpdateVendorData, UpdateVendorVariables>;
|
||||
export function updateVendor(dc: DataConnect, vars: UpdateVendorVariables): MutationPromise<UpdateVendorData, UpdateVendorVariables>;
|
||||
|
||||
interface DeleteVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: DeleteVendorVariables): MutationRef<DeleteVendorData, DeleteVendorVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: DeleteVendorVariables): MutationRef<DeleteVendorData, DeleteVendorVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const deleteVendorRef: DeleteVendorRef;
|
||||
|
||||
export function deleteVendor(vars: DeleteVendorVariables): MutationPromise<DeleteVendorData, DeleteVendorVariables>;
|
||||
export function deleteVendor(dc: DataConnect, vars: DeleteVendorVariables): MutationPromise<DeleteVendorData, DeleteVendorVariables>;
|
||||
|
||||
interface ListVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(): QueryRef<ListVendorData, undefined>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect): QueryRef<ListVendorData, undefined>;
|
||||
operationName: string;
|
||||
}
|
||||
export const listVendorRef: ListVendorRef;
|
||||
|
||||
export function listVendor(): QueryPromise<ListVendorData, undefined>;
|
||||
export function listVendor(dc: DataConnect): QueryPromise<ListVendorData, undefined>;
|
||||
|
||||
interface GetVendorByIdRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: GetVendorByIdVariables): QueryRef<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: GetVendorByIdVariables): QueryRef<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const getVendorByIdRef: GetVendorByIdRef;
|
||||
|
||||
export function getVendorById(vars: GetVendorByIdVariables): QueryPromise<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
export function getVendorById(dc: DataConnect, vars: GetVendorByIdVariables): QueryPromise<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
|
||||
interface FilterVendorsRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars?: FilterVendorsVariables): QueryRef<FilterVendorsData, FilterVendorsVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars?: FilterVendorsVariables): QueryRef<FilterVendorsData, FilterVendorsVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const filterVendorsRef: FilterVendorsRef;
|
||||
|
||||
export function filterVendors(vars?: FilterVendorsVariables): QueryPromise<FilterVendorsData, FilterVendorsVariables>;
|
||||
export function filterVendors(dc: DataConnect, vars?: FilterVendorsVariables): QueryPromise<FilterVendorsData, FilterVendorsVariables>;
|
||||
|
||||
interface CreateEventRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const createEventRef: CreateEventRef;
|
||||
|
||||
export function createEvent(vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
|
||||
|
||||
@@ -17,13 +17,17 @@ You can also follow the instructions from the [Data Connect documentation](https
|
||||
- [**Accessing the connector**](#accessing-the-connector)
|
||||
- [*Connecting to the local Emulator*](#connecting-to-the-local-emulator)
|
||||
- [**Queries**](#queries)
|
||||
- [*listVendor*](#listvendor)
|
||||
- [*listEvents*](#listevents)
|
||||
- [*listStaff*](#liststaff)
|
||||
- [*listVendor*](#listvendor)
|
||||
- [*getVendorById*](#getvendorbyid)
|
||||
- [*filterVendors*](#filtervendors)
|
||||
- [**Mutations**](#mutations)
|
||||
- [*CreateEvent*](#createevent)
|
||||
- [*CreateStaff*](#createstaff)
|
||||
- [*CreateVendor*](#createvendor)
|
||||
- [*UpdateVendor*](#updatevendor)
|
||||
- [*DeleteVendor*](#deletevendor)
|
||||
- [*CreateEvent*](#createevent)
|
||||
|
||||
# TanStack Query Firebase & TanStack React Query
|
||||
This SDK provides [React](https://react.dev/) hooks generated specific to your application, for the operations found in the connector `krow-connector`. These hooks are generated using [TanStack Query Firebase](https://react-query-firebase.invertase.dev/) by our partners at Invertase, a library built on top of [TanStack React Query v5](https://tanstack.com/query/v5/docs/framework/react/overview).
|
||||
@@ -115,84 +119,6 @@ Here's a general overview of how to use the generated Query hooks in your code:
|
||||
|
||||
Below are examples of how to use the `krow-connector` connector's generated Query hook functions to execute each Query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular).
|
||||
|
||||
## listVendor
|
||||
You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `listVendor` Query has no variables.
|
||||
### Return Type
|
||||
Recall that calling the `listVendor` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface ListVendorData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `listVendor`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig } from '@dataconnect/generated';
|
||||
import { useListVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function ListVendorComponent() {
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useListVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useListVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(dataConnect, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendors);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## listEvents
|
||||
You can execute the `listEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
@@ -353,6 +279,284 @@ export default function ListStaffComponent() {
|
||||
}
|
||||
```
|
||||
|
||||
## listVendor
|
||||
You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `listVendor` Query has no variables.
|
||||
### Return Type
|
||||
Recall that calling the `listVendor` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface ListVendorData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `listVendor`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig } from '@dataconnect/generated';
|
||||
import { useListVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function ListVendorComponent() {
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useListVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useListVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(dataConnect, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendors);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## getVendorById
|
||||
You can execute the `getVendorById` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `getVendorById` Query requires an argument of type `GetVendorByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface GetVendorByIdVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `getVendorById` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `getVendorById` Query is of type `GetVendorByIdData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface GetVendorByIdData {
|
||||
vendor?: {
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `getVendorById`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, GetVendorByIdVariables } from '@dataconnect/generated';
|
||||
import { useGetVendorById } from '@dataconnect/generated/react'
|
||||
|
||||
export default function GetVendorByIdComponent() {
|
||||
// The `useGetVendorById` Query hook requires an argument of type `GetVendorByIdVariables`:
|
||||
const getVendorByIdVars: GetVendorByIdVariables = {
|
||||
id: ...,
|
||||
};
|
||||
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useGetVendorById(getVendorByIdVars);
|
||||
// Variables can be defined inline as well.
|
||||
const query = useGetVendorById({ id: ..., });
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useGetVendorById(dataConnect, getVendorByIdVars);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useGetVendorById(getVendorByIdVars, options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useGetVendorById(dataConnect, getVendorByIdVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendor);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## filterVendors
|
||||
You can execute the `filterVendors` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `filterVendors` Query has an optional argument of type `FilterVendorsVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
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 calling the `filterVendors` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `filterVendors` Query is of type `FilterVendorsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface FilterVendorsData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `filterVendors`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, FilterVendorsVariables } from '@dataconnect/generated';
|
||||
import { useFilterVendors } from '@dataconnect/generated/react'
|
||||
|
||||
export default function FilterVendorsComponent() {
|
||||
// The `useFilterVendors` Query hook has an optional argument of type `FilterVendorsVariables`:
|
||||
const filterVendorsVars: FilterVendorsVariables = {
|
||||
region: ..., // optional
|
||||
approvalStatus: ..., // optional
|
||||
isActive: ..., // optional
|
||||
vendorNumber: ..., // optional
|
||||
primaryContactEmail: ..., // optional
|
||||
legalName: ..., // optional
|
||||
platformType: ..., // optional
|
||||
};
|
||||
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useFilterVendors(filterVendorsVars);
|
||||
// Variables can be defined inline as well.
|
||||
const query = useFilterVendors({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., });
|
||||
// Since all variables are optional for this Query, you can omit the `FilterVendorsVariables` argument.
|
||||
// (as long as you don't want to provide any `options`!)
|
||||
const query = useFilterVendors();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useFilterVendors(dataConnect, filterVendorsVars);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useFilterVendors(filterVendorsVars, options);
|
||||
// If you'd like to provide options without providing any variables, you must
|
||||
// pass `undefined` where you would normally pass the variables.
|
||||
const query = useFilterVendors(undefined, options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useFilterVendors(dataConnect, filterVendorsVars /** or undefined */, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendors);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
# Mutations
|
||||
|
||||
The React generated SDK provides Mutations hook functions that call and return [`useDataConnectMutation`](https://react-query-firebase.invertase.dev/react/data-connect/mutations) hooks from TanStack Query Firebase.
|
||||
@@ -378,120 +582,6 @@ Here's a general overview of how to use the generated Mutation hooks in your cod
|
||||
|
||||
Below are examples of how to use the `krow-connector` connector's generated Mutation hook functions to execute each Mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular).
|
||||
|
||||
## CreateEvent
|
||||
You can execute the `CreateEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface CreateEventVariables {
|
||||
eventName: string;
|
||||
isRecurring: boolean;
|
||||
recurrenceType?: RecurrenceType | null;
|
||||
businessId: UUIDString;
|
||||
vendorId?: UUIDString | null;
|
||||
status: EventStatus;
|
||||
date: TimestampString;
|
||||
shifts?: string | null;
|
||||
total?: number | null;
|
||||
requested?: number | null;
|
||||
assignedStaff?: string | null;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `CreateEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface CreateEventData {
|
||||
event_insert: Event_Key;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `CreateEvent`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, CreateEventVariables } from '@dataconnect/generated';
|
||||
import { useCreateEvent } from '@dataconnect/generated/react'
|
||||
|
||||
export default function CreateEventComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useCreateEvent();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useCreateEvent(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`:
|
||||
const createEventVars: CreateEventVariables = {
|
||||
eventName: ...,
|
||||
isRecurring: ...,
|
||||
recurrenceType: ..., // optional
|
||||
businessId: ...,
|
||||
vendorId: ..., // optional
|
||||
status: ...,
|
||||
date: ...,
|
||||
shifts: ..., // optional
|
||||
total: ..., // optional
|
||||
requested: ..., // optional
|
||||
assignedStaff: ..., // optional
|
||||
};
|
||||
mutation.mutate(createEventVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(createEventVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.event_insert);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## CreateStaff
|
||||
You can execute the `CreateStaff` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
@@ -708,3 +798,319 @@ export default function CreateVendorComponent() {
|
||||
}
|
||||
```
|
||||
|
||||
## UpdateVendor
|
||||
You can execute the `UpdateVendor` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useUpdateVendor(options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `UpdateVendor` Mutation requires an argument of type `UpdateVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
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 calling the `UpdateVendor` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `UpdateVendor` Mutation is of type `UpdateVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface UpdateVendorData {
|
||||
vendor_update?: Vendor_Key | null;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `UpdateVendor`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, UpdateVendorVariables } from '@dataconnect/generated';
|
||||
import { useUpdateVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function UpdateVendorComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useUpdateVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useUpdateVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useUpdateVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useUpdateVendor(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useUpdateVendor` 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
|
||||
};
|
||||
mutation.mutate(updateVendorVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(updateVendorVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.vendor_update);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## DeleteVendor
|
||||
You can execute the `DeleteVendor` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useDeleteVendor(options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `DeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface DeleteVendorVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `DeleteVendor` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `DeleteVendor` Mutation is of type `DeleteVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface DeleteVendorData {
|
||||
vendor_delete?: Vendor_Key | null;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `DeleteVendor`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, DeleteVendorVariables } from '@dataconnect/generated';
|
||||
import { useDeleteVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function DeleteVendorComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useDeleteVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useDeleteVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useDeleteVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useDeleteVendor(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useDeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`:
|
||||
const deleteVendorVars: DeleteVendorVariables = {
|
||||
id: ...,
|
||||
};
|
||||
mutation.mutate(deleteVendorVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ id: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(deleteVendorVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.vendor_delete);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## CreateEvent
|
||||
You can execute the `CreateEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface CreateEventVariables {
|
||||
eventName: string;
|
||||
isRecurring: boolean;
|
||||
recurrenceType?: RecurrenceType | null;
|
||||
businessId: UUIDString;
|
||||
vendorId?: UUIDString | null;
|
||||
status: EventStatus;
|
||||
date: TimestampString;
|
||||
shifts?: string | null;
|
||||
total?: number | null;
|
||||
requested?: number | null;
|
||||
assignedStaff?: string | null;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `CreateEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface CreateEventData {
|
||||
event_insert: Event_Key;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `CreateEvent`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, CreateEventVariables } from '@dataconnect/generated';
|
||||
import { useCreateEvent } from '@dataconnect/generated/react'
|
||||
|
||||
export default function CreateEventComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useCreateEvent();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useCreateEvent(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`:
|
||||
const createEventVars: CreateEventVariables = {
|
||||
eventName: ...,
|
||||
isRecurring: ...,
|
||||
recurrenceType: ..., // optional
|
||||
businessId: ...,
|
||||
vendorId: ..., // optional
|
||||
status: ...,
|
||||
date: ...,
|
||||
shifts: ..., // optional
|
||||
total: ..., // optional
|
||||
requested: ..., // optional
|
||||
assignedStaff: ..., // optional
|
||||
};
|
||||
mutation.mutate(createEventVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(createEventVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.event_insert);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
import { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } from '../../esm/index.esm.js';
|
||||
import { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } from '../../esm/index.esm.js';
|
||||
import { validateArgs, CallerSdkTypeEnum } from 'firebase/data-connect';
|
||||
import { useDataConnectQuery, useDataConnectMutation, validateReactArgs } from '@tanstack-query-firebase/react/data-connect';
|
||||
|
||||
|
||||
export function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
export function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
export function useListEvents(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listEventsRef(dcInstance);
|
||||
@@ -43,3 +29,45 @@ export function useCreateVendor(dcOrOptions, options) {
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useUpdateVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return updateVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useDeleteVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return deleteVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
export function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useGetVendorById(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true);
|
||||
const ref = getVendorByIdRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useFilterVendors(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false);
|
||||
const ref = filterVendorsRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
export function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
const { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } = require('../index.cjs.js');
|
||||
const { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } = require('../index.cjs.js');
|
||||
const { validateArgs, CallerSdkTypeEnum } = require('firebase/data-connect');
|
||||
const { useDataConnectQuery, useDataConnectMutation, validateReactArgs } = require('@tanstack-query-firebase/react/data-connect');
|
||||
|
||||
|
||||
exports.useListVendor = function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
exports.useListEvents = function useListEvents(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listEventsRef(dcInstance);
|
||||
@@ -43,3 +29,45 @@ exports.useCreateVendor = function useCreateVendor(dcOrOptions, options) {
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useUpdateVendor = function useUpdateVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return updateVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useDeleteVendor = function useDeleteVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return deleteVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
exports.useListVendor = function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useGetVendorById = function useGetVendorById(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true);
|
||||
const ref = getVendorByIdRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useFilterVendors = function useFilterVendors(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false);
|
||||
const ref = filterVendorsRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import { ListVendorData, CreateEventData, CreateEventVariables, ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables } from '../';
|
||||
import { ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables } from '../';
|
||||
import { UseDataConnectQueryResult, useDataConnectQueryOptions, UseDataConnectMutationResult, useDataConnectMutationOptions} from '@tanstack-query-firebase/react/data-connect';
|
||||
import { UseQueryResult, UseMutationResult} from '@tanstack/react-query';
|
||||
import { DataConnect } from 'firebase/data-connect';
|
||||
import { FirebaseError } from 'firebase/app';
|
||||
|
||||
|
||||
export function useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
|
||||
export function useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
|
||||
export function useListEvents(options?: useDataConnectQueryOptions<ListEventsData>): UseDataConnectQueryResult<ListEventsData, undefined>;
|
||||
export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions<ListEventsData>): UseDataConnectQueryResult<ListEventsData, undefined>;
|
||||
|
||||
@@ -22,3 +16,21 @@ export function useListStaff(dc: DataConnect, options?: useDataConnectQueryOptio
|
||||
|
||||
export function useCreateVendor(options?: useDataConnectMutationOptions<CreateVendorData, FirebaseError, CreateVendorVariables>): UseDataConnectMutationResult<CreateVendorData, CreateVendorVariables>;
|
||||
export function useCreateVendor(dc: DataConnect, options?: useDataConnectMutationOptions<CreateVendorData, FirebaseError, CreateVendorVariables>): UseDataConnectMutationResult<CreateVendorData, CreateVendorVariables>;
|
||||
|
||||
export function useUpdateVendor(options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
export function useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
|
||||
export function useDeleteVendor(options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
export function useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
|
||||
export function useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
|
||||
export function useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
export function useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
|
||||
export function useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
export function useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
|
||||
export function useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
|
||||
@@ -12,13 +12,9 @@ For each operation, there is a wrapper hook that can be used to call the operati
|
||||
|
||||
Here are all of the hooks that get generated:
|
||||
```ts
|
||||
import { useListVendor, useCreateEvent, useListEvents, useCreateStaff, useListStaff, useCreateVendor } from '@dataconnect/generated/react';
|
||||
import { useListEvents, useCreateStaff, useListStaff, useCreateVendor, useUpdateVendor, useDeleteVendor, useListVendor, useGetVendorById, useFilterVendors, useCreateEvent } from '@dataconnect/generated/react';
|
||||
// The types of these hooks are available in react/index.d.ts
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useListVendor();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useListEvents();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateStaff(createStaffVars);
|
||||
@@ -27,6 +23,18 @@ const { data, isPending, isSuccess, isError, error } = useListStaff();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateVendor(createVendorVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useUpdateVendor(updateVendorVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useDeleteVendor(deleteVendorVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useListVendor();
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useGetVendorById(getVendorByIdVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useFilterVendors(filterVendorsVars);
|
||||
|
||||
const { data, isPending, isSuccess, isError, error } = useCreateEvent(createEventVars);
|
||||
|
||||
```
|
||||
|
||||
Here's an example from a different generated SDK:
|
||||
@@ -64,15 +72,9 @@ If a user is not using a supported framework, they can use the generated SDK dir
|
||||
Here's an example of how to use it with the first 5 operations:
|
||||
|
||||
```js
|
||||
import { listVendor, createEvent, listEvents, createStaff, listStaff, createVendor } from '@dataconnect/generated';
|
||||
import { listEvents, createStaff, listStaff, createVendor, updateVendor, deleteVendor, listVendor, getVendorById, filterVendors, createEvent } from '@dataconnect/generated';
|
||||
|
||||
|
||||
// Operation listVendor:
|
||||
const { data } = await ListVendor(dataConnect);
|
||||
|
||||
// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts
|
||||
const { data } = await CreateEvent(dataConnect, createEventVars);
|
||||
|
||||
// Operation listEvents:
|
||||
const { data } = await ListEvents(dataConnect);
|
||||
|
||||
@@ -85,5 +87,23 @@ const { data } = await ListStaff(dataConnect);
|
||||
// Operation CreateVendor: For variables, look at type CreateVendorVars in ../index.d.ts
|
||||
const { data } = await CreateVendor(dataConnect, createVendorVars);
|
||||
|
||||
// Operation UpdateVendor: For variables, look at type UpdateVendorVars in ../index.d.ts
|
||||
const { data } = await UpdateVendor(dataConnect, updateVendorVars);
|
||||
|
||||
// Operation DeleteVendor: For variables, look at type DeleteVendorVars in ../index.d.ts
|
||||
const { data } = await DeleteVendor(dataConnect, deleteVendorVars);
|
||||
|
||||
// Operation listVendor:
|
||||
const { data } = await ListVendor(dataConnect);
|
||||
|
||||
// Operation getVendorById: For variables, look at type GetVendorByIdVars in ../index.d.ts
|
||||
const { data } = await GetVendorById(dataConnect, getVendorByIdVars);
|
||||
|
||||
// Operation filterVendors: For variables, look at type FilterVendorsVars in ../index.d.ts
|
||||
const { data } = await FilterVendors(dataConnect, filterVendorsVars);
|
||||
|
||||
// Operation CreateEvent: For variables, look at type CreateEventVars in ../index.d.ts
|
||||
const { data } = await CreateEvent(dataConnect, createEventVars);
|
||||
|
||||
|
||||
```
|
||||
File diff suppressed because it is too large
Load Diff
@@ -61,28 +61,6 @@ export const connectorConfig = {
|
||||
location: 'us-central1'
|
||||
};
|
||||
|
||||
export const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
|
||||
export function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
}
|
||||
|
||||
export const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
|
||||
export function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const listEventsRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
@@ -127,3 +105,69 @@ export function createVendor(dcOrVars, vars) {
|
||||
return executeMutation(createVendorRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const updateVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'UpdateVendor', inputVars);
|
||||
}
|
||||
updateVendorRef.operationName = 'UpdateVendor';
|
||||
|
||||
export function updateVendor(dcOrVars, vars) {
|
||||
return executeMutation(updateVendorRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const deleteVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'DeleteVendor', inputVars);
|
||||
}
|
||||
deleteVendorRef.operationName = 'DeleteVendor';
|
||||
|
||||
export function deleteVendor(dcOrVars, vars) {
|
||||
return executeMutation(deleteVendorRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
|
||||
export function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
}
|
||||
|
||||
export const getVendorByIdRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'getVendorById', inputVars);
|
||||
}
|
||||
getVendorByIdRef.operationName = 'getVendorById';
|
||||
|
||||
export function getVendorById(dcOrVars, vars) {
|
||||
return executeQuery(getVendorByIdRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const filterVendorsRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'filterVendors', inputVars);
|
||||
}
|
||||
filterVendorsRef.operationName = 'filterVendors';
|
||||
|
||||
export function filterVendors(dcOrVars, vars) {
|
||||
return executeQuery(filterVendorsRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
export const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
|
||||
export function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
}
|
||||
|
||||
|
||||
@@ -69,30 +69,6 @@ const connectorConfig = {
|
||||
};
|
||||
exports.connectorConfig = connectorConfig;
|
||||
|
||||
const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
exports.listVendorRef = listVendorRef;
|
||||
|
||||
exports.listVendor = function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
};
|
||||
|
||||
const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
exports.createEventRef = createEventRef;
|
||||
|
||||
exports.createEvent = function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const listEventsRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
@@ -140,3 +116,75 @@ exports.createVendorRef = createVendorRef;
|
||||
exports.createVendor = function createVendor(dcOrVars, vars) {
|
||||
return executeMutation(createVendorRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const updateVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'UpdateVendor', inputVars);
|
||||
}
|
||||
updateVendorRef.operationName = 'UpdateVendor';
|
||||
exports.updateVendorRef = updateVendorRef;
|
||||
|
||||
exports.updateVendor = function updateVendor(dcOrVars, vars) {
|
||||
return executeMutation(updateVendorRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const deleteVendorRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'DeleteVendor', inputVars);
|
||||
}
|
||||
deleteVendorRef.operationName = 'DeleteVendor';
|
||||
exports.deleteVendorRef = deleteVendorRef;
|
||||
|
||||
exports.deleteVendor = function deleteVendor(dcOrVars, vars) {
|
||||
return executeMutation(deleteVendorRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const listVendorRef = (dc) => {
|
||||
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'listVendor');
|
||||
}
|
||||
listVendorRef.operationName = 'listVendor';
|
||||
exports.listVendorRef = listVendorRef;
|
||||
|
||||
exports.listVendor = function listVendor(dc) {
|
||||
return executeQuery(listVendorRef(dc));
|
||||
};
|
||||
|
||||
const getVendorByIdRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'getVendorById', inputVars);
|
||||
}
|
||||
getVendorByIdRef.operationName = 'getVendorById';
|
||||
exports.getVendorByIdRef = getVendorByIdRef;
|
||||
|
||||
exports.getVendorById = function getVendorById(dcOrVars, vars) {
|
||||
return executeQuery(getVendorByIdRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const filterVendorsRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return queryRef(dcInstance, 'filterVendors', inputVars);
|
||||
}
|
||||
filterVendorsRef.operationName = 'filterVendors';
|
||||
exports.filterVendorsRef = filterVendorsRef;
|
||||
|
||||
exports.filterVendors = function filterVendors(dcOrVars, vars) {
|
||||
return executeQuery(filterVendorsRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
const createEventRef = (dcOrVars, vars) => {
|
||||
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
|
||||
dcInstance._useGeneratedSdk();
|
||||
return mutationRef(dcInstance, 'CreateEvent', inputVars);
|
||||
}
|
||||
createEventRef.operationName = 'CreateEvent';
|
||||
exports.createEventRef = createEventRef;
|
||||
|
||||
exports.createEvent = function createEvent(dcOrVars, vars) {
|
||||
return executeMutation(createEventRef(dcOrVars, vars));
|
||||
};
|
||||
|
||||
@@ -113,11 +113,59 @@ export interface CreateVendorVariables {
|
||||
isActive?: boolean | null;
|
||||
}
|
||||
|
||||
export interface DeleteVendorData {
|
||||
vendor_delete?: Vendor_Key | null;
|
||||
}
|
||||
|
||||
export interface DeleteVendorVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
|
||||
export interface Event_Key {
|
||||
id: UUIDString;
|
||||
__typename?: 'Event_Key';
|
||||
}
|
||||
|
||||
export interface FilterVendorsData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
|
||||
export interface FilterVendorsVariables {
|
||||
region?: VendorRegion | null;
|
||||
approvalStatus?: VendorApprovalStatus | null;
|
||||
isActive?: boolean | null;
|
||||
vendorNumber?: string | null;
|
||||
primaryContactEmail?: string | null;
|
||||
legalName?: string | null;
|
||||
platformType?: VendorPlatformType | null;
|
||||
}
|
||||
|
||||
export interface GetVendorByIdData {
|
||||
vendor?: {
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key;
|
||||
}
|
||||
|
||||
export interface GetVendorByIdVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
|
||||
export interface ListEventsData {
|
||||
events: ({
|
||||
id: UUIDString;
|
||||
@@ -166,35 +214,26 @@ export interface Staff_Key {
|
||||
__typename?: 'Staff_Key';
|
||||
}
|
||||
|
||||
export interface UpdateVendorData {
|
||||
vendor_update?: Vendor_Key | null;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
export interface Vendor_Key {
|
||||
id: UUIDString;
|
||||
__typename?: 'Vendor_Key';
|
||||
}
|
||||
|
||||
interface ListVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(): QueryRef<ListVendorData, undefined>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect): QueryRef<ListVendorData, undefined>;
|
||||
operationName: string;
|
||||
}
|
||||
export const listVendorRef: ListVendorRef;
|
||||
|
||||
export function listVendor(): QueryPromise<ListVendorData, undefined>;
|
||||
export function listVendor(dc: DataConnect): QueryPromise<ListVendorData, undefined>;
|
||||
|
||||
interface CreateEventRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const createEventRef: CreateEventRef;
|
||||
|
||||
export function createEvent(vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
|
||||
interface ListEventsRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(): QueryRef<ListEventsData, undefined>;
|
||||
@@ -243,3 +282,75 @@ export const createVendorRef: CreateVendorRef;
|
||||
export function createVendor(vars: CreateVendorVariables): MutationPromise<CreateVendorData, CreateVendorVariables>;
|
||||
export function createVendor(dc: DataConnect, vars: CreateVendorVariables): MutationPromise<CreateVendorData, CreateVendorVariables>;
|
||||
|
||||
interface UpdateVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: UpdateVendorVariables): MutationRef<UpdateVendorData, UpdateVendorVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: UpdateVendorVariables): MutationRef<UpdateVendorData, UpdateVendorVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const updateVendorRef: UpdateVendorRef;
|
||||
|
||||
export function updateVendor(vars: UpdateVendorVariables): MutationPromise<UpdateVendorData, UpdateVendorVariables>;
|
||||
export function updateVendor(dc: DataConnect, vars: UpdateVendorVariables): MutationPromise<UpdateVendorData, UpdateVendorVariables>;
|
||||
|
||||
interface DeleteVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: DeleteVendorVariables): MutationRef<DeleteVendorData, DeleteVendorVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: DeleteVendorVariables): MutationRef<DeleteVendorData, DeleteVendorVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const deleteVendorRef: DeleteVendorRef;
|
||||
|
||||
export function deleteVendor(vars: DeleteVendorVariables): MutationPromise<DeleteVendorData, DeleteVendorVariables>;
|
||||
export function deleteVendor(dc: DataConnect, vars: DeleteVendorVariables): MutationPromise<DeleteVendorData, DeleteVendorVariables>;
|
||||
|
||||
interface ListVendorRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(): QueryRef<ListVendorData, undefined>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect): QueryRef<ListVendorData, undefined>;
|
||||
operationName: string;
|
||||
}
|
||||
export const listVendorRef: ListVendorRef;
|
||||
|
||||
export function listVendor(): QueryPromise<ListVendorData, undefined>;
|
||||
export function listVendor(dc: DataConnect): QueryPromise<ListVendorData, undefined>;
|
||||
|
||||
interface GetVendorByIdRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: GetVendorByIdVariables): QueryRef<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: GetVendorByIdVariables): QueryRef<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const getVendorByIdRef: GetVendorByIdRef;
|
||||
|
||||
export function getVendorById(vars: GetVendorByIdVariables): QueryPromise<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
export function getVendorById(dc: DataConnect, vars: GetVendorByIdVariables): QueryPromise<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
|
||||
interface FilterVendorsRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars?: FilterVendorsVariables): QueryRef<FilterVendorsData, FilterVendorsVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars?: FilterVendorsVariables): QueryRef<FilterVendorsData, FilterVendorsVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const filterVendorsRef: FilterVendorsRef;
|
||||
|
||||
export function filterVendors(vars?: FilterVendorsVariables): QueryPromise<FilterVendorsData, FilterVendorsVariables>;
|
||||
export function filterVendors(dc: DataConnect, vars?: FilterVendorsVariables): QueryPromise<FilterVendorsData, FilterVendorsVariables>;
|
||||
|
||||
interface CreateEventRef {
|
||||
/* Allow users to create refs without passing in DataConnect */
|
||||
(vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
/* Allow users to pass in custom DataConnect instances */
|
||||
(dc: DataConnect, vars: CreateEventVariables): MutationRef<CreateEventData, CreateEventVariables>;
|
||||
operationName: string;
|
||||
}
|
||||
export const createEventRef: CreateEventRef;
|
||||
|
||||
export function createEvent(vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
export function createEvent(dc: DataConnect, vars: CreateEventVariables): MutationPromise<CreateEventData, CreateEventVariables>;
|
||||
|
||||
|
||||
@@ -17,13 +17,17 @@ You can also follow the instructions from the [Data Connect documentation](https
|
||||
- [**Accessing the connector**](#accessing-the-connector)
|
||||
- [*Connecting to the local Emulator*](#connecting-to-the-local-emulator)
|
||||
- [**Queries**](#queries)
|
||||
- [*listVendor*](#listvendor)
|
||||
- [*listEvents*](#listevents)
|
||||
- [*listStaff*](#liststaff)
|
||||
- [*listVendor*](#listvendor)
|
||||
- [*getVendorById*](#getvendorbyid)
|
||||
- [*filterVendors*](#filtervendors)
|
||||
- [**Mutations**](#mutations)
|
||||
- [*CreateEvent*](#createevent)
|
||||
- [*CreateStaff*](#createstaff)
|
||||
- [*CreateVendor*](#createvendor)
|
||||
- [*UpdateVendor*](#updatevendor)
|
||||
- [*DeleteVendor*](#deletevendor)
|
||||
- [*CreateEvent*](#createevent)
|
||||
|
||||
# TanStack Query Firebase & TanStack React Query
|
||||
This SDK provides [React](https://react.dev/) hooks generated specific to your application, for the operations found in the connector `krow-connector`. These hooks are generated using [TanStack Query Firebase](https://react-query-firebase.invertase.dev/) by our partners at Invertase, a library built on top of [TanStack React Query v5](https://tanstack.com/query/v5/docs/framework/react/overview).
|
||||
@@ -115,84 +119,6 @@ Here's a general overview of how to use the generated Query hooks in your code:
|
||||
|
||||
Below are examples of how to use the `krow-connector` connector's generated Query hook functions to execute each Query. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular).
|
||||
|
||||
## listVendor
|
||||
You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `listVendor` Query has no variables.
|
||||
### Return Type
|
||||
Recall that calling the `listVendor` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface ListVendorData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `listVendor`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig } from '@dataconnect/generated';
|
||||
import { useListVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function ListVendorComponent() {
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useListVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useListVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(dataConnect, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendors);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## listEvents
|
||||
You can execute the `listEvents` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
@@ -353,6 +279,284 @@ export default function ListStaffComponent() {
|
||||
}
|
||||
```
|
||||
|
||||
## listVendor
|
||||
You can execute the `listVendor` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `listVendor` Query has no variables.
|
||||
### Return Type
|
||||
Recall that calling the `listVendor` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `listVendor` Query is of type `ListVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface ListVendorData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `listVendor`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig } from '@dataconnect/generated';
|
||||
import { useListVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function ListVendorComponent() {
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useListVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useListVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useListVendor(dataConnect, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendors);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## getVendorById
|
||||
You can execute the `getVendorById` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `getVendorById` Query requires an argument of type `GetVendorByIdVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface GetVendorByIdVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `getVendorById` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `getVendorById` Query is of type `GetVendorByIdData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface GetVendorByIdData {
|
||||
vendor?: {
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `getVendorById`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, GetVendorByIdVariables } from '@dataconnect/generated';
|
||||
import { useGetVendorById } from '@dataconnect/generated/react'
|
||||
|
||||
export default function GetVendorByIdComponent() {
|
||||
// The `useGetVendorById` Query hook requires an argument of type `GetVendorByIdVariables`:
|
||||
const getVendorByIdVars: GetVendorByIdVariables = {
|
||||
id: ...,
|
||||
};
|
||||
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useGetVendorById(getVendorByIdVars);
|
||||
// Variables can be defined inline as well.
|
||||
const query = useGetVendorById({ id: ..., });
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useGetVendorById(dataConnect, getVendorByIdVars);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useGetVendorById(getVendorByIdVars, options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useGetVendorById(dataConnect, getVendorByIdVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendor);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## filterVendors
|
||||
You can execute the `filterVendors` Query using the following Query hook function, which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts):
|
||||
|
||||
```javascript
|
||||
useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
```javascript
|
||||
useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `filterVendors` Query has an optional argument of type `FilterVendorsVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
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 calling the `filterVendors` Query hook function returns a `UseQueryResult` object. This object holds the state of your Query, including whether the Query is loading, has completed, or has succeeded/failed, and any data returned by the Query, among other things.
|
||||
|
||||
To check the status of a Query, use the `UseQueryResult.status` field. You can also check for pending / success / error status using the `UseQueryResult.isPending`, `UseQueryResult.isSuccess`, and `UseQueryResult.isError` fields.
|
||||
|
||||
To access the data returned by a Query, use the `UseQueryResult.data` field. The data for the `filterVendors` Query is of type `FilterVendorsData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface FilterVendorsData {
|
||||
vendors: ({
|
||||
id: UUIDString;
|
||||
vendorNumber: string;
|
||||
legalName: string;
|
||||
region: VendorRegion;
|
||||
platformType: VendorPlatformType;
|
||||
primaryContactEmail: string;
|
||||
approvalStatus: VendorApprovalStatus;
|
||||
isActive?: boolean | null;
|
||||
} & Vendor_Key)[];
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseQueryResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useQuery).
|
||||
|
||||
### Using `filterVendors`'s Query hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, FilterVendorsVariables } from '@dataconnect/generated';
|
||||
import { useFilterVendors } from '@dataconnect/generated/react'
|
||||
|
||||
export default function FilterVendorsComponent() {
|
||||
// The `useFilterVendors` Query hook has an optional argument of type `FilterVendorsVariables`:
|
||||
const filterVendorsVars: FilterVendorsVariables = {
|
||||
region: ..., // optional
|
||||
approvalStatus: ..., // optional
|
||||
isActive: ..., // optional
|
||||
vendorNumber: ..., // optional
|
||||
primaryContactEmail: ..., // optional
|
||||
legalName: ..., // optional
|
||||
platformType: ..., // optional
|
||||
};
|
||||
|
||||
// You don't have to do anything to "execute" the Query.
|
||||
// Call the Query hook function to get a `UseQueryResult` object which holds the state of your Query.
|
||||
const query = useFilterVendors(filterVendorsVars);
|
||||
// Variables can be defined inline as well.
|
||||
const query = useFilterVendors({ region: ..., approvalStatus: ..., isActive: ..., vendorNumber: ..., primaryContactEmail: ..., legalName: ..., platformType: ..., });
|
||||
// Since all variables are optional for this Query, you can omit the `FilterVendorsVariables` argument.
|
||||
// (as long as you don't want to provide any `options`!)
|
||||
const query = useFilterVendors();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Query hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const query = useFilterVendors(dataConnect, filterVendorsVars);
|
||||
|
||||
// You can also pass in a `useDataConnectQueryOptions` object to the Query hook function.
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useFilterVendors(filterVendorsVars, options);
|
||||
// If you'd like to provide options without providing any variables, you must
|
||||
// pass `undefined` where you would normally pass the variables.
|
||||
const query = useFilterVendors(undefined, options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectQueryOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = { staleTime: 5 * 1000 };
|
||||
const query = useFilterVendors(dataConnect, filterVendorsVars /** or undefined */, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Query.
|
||||
if (query.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (query.isError) {
|
||||
return <div>Error: {query.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Query is successful, you can access the data returned using the `UseQueryResult.data` field.
|
||||
if (query.isSuccess) {
|
||||
console.log(query.data.vendors);
|
||||
}
|
||||
return <div>Query execution {query.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
# Mutations
|
||||
|
||||
The React generated SDK provides Mutations hook functions that call and return [`useDataConnectMutation`](https://react-query-firebase.invertase.dev/react/data-connect/mutations) hooks from TanStack Query Firebase.
|
||||
@@ -378,120 +582,6 @@ Here's a general overview of how to use the generated Mutation hooks in your cod
|
||||
|
||||
Below are examples of how to use the `krow-connector` connector's generated Mutation hook functions to execute each Mutation. You can also follow the examples from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#operations-react-angular).
|
||||
|
||||
## CreateEvent
|
||||
You can execute the `CreateEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface CreateEventVariables {
|
||||
eventName: string;
|
||||
isRecurring: boolean;
|
||||
recurrenceType?: RecurrenceType | null;
|
||||
businessId: UUIDString;
|
||||
vendorId?: UUIDString | null;
|
||||
status: EventStatus;
|
||||
date: TimestampString;
|
||||
shifts?: string | null;
|
||||
total?: number | null;
|
||||
requested?: number | null;
|
||||
assignedStaff?: string | null;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `CreateEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface CreateEventData {
|
||||
event_insert: Event_Key;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `CreateEvent`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, CreateEventVariables } from '@dataconnect/generated';
|
||||
import { useCreateEvent } from '@dataconnect/generated/react'
|
||||
|
||||
export default function CreateEventComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useCreateEvent();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useCreateEvent(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`:
|
||||
const createEventVars: CreateEventVariables = {
|
||||
eventName: ...,
|
||||
isRecurring: ...,
|
||||
recurrenceType: ..., // optional
|
||||
businessId: ...,
|
||||
vendorId: ..., // optional
|
||||
status: ...,
|
||||
date: ...,
|
||||
shifts: ..., // optional
|
||||
total: ..., // optional
|
||||
requested: ..., // optional
|
||||
assignedStaff: ..., // optional
|
||||
};
|
||||
mutation.mutate(createEventVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(createEventVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.event_insert);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## CreateStaff
|
||||
You can execute the `CreateStaff` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
@@ -708,3 +798,319 @@ export default function CreateVendorComponent() {
|
||||
}
|
||||
```
|
||||
|
||||
## UpdateVendor
|
||||
You can execute the `UpdateVendor` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useUpdateVendor(options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `UpdateVendor` Mutation requires an argument of type `UpdateVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
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 calling the `UpdateVendor` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `UpdateVendor` Mutation is of type `UpdateVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface UpdateVendorData {
|
||||
vendor_update?: Vendor_Key | null;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `UpdateVendor`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, UpdateVendorVariables } from '@dataconnect/generated';
|
||||
import { useUpdateVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function UpdateVendorComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useUpdateVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useUpdateVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useUpdateVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useUpdateVendor(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useUpdateVendor` 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
|
||||
};
|
||||
mutation.mutate(updateVendorVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ id: ..., vendorNumber: ..., legalName: ..., region: ..., platformType: ..., primaryContactEmail: ..., approvalStatus: ..., isActive: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(updateVendorVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.vendor_update);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## DeleteVendor
|
||||
You can execute the `DeleteVendor` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useDeleteVendor(options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `DeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface DeleteVendorVariables {
|
||||
id: UUIDString;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `DeleteVendor` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `DeleteVendor` Mutation is of type `DeleteVendorData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface DeleteVendorData {
|
||||
vendor_delete?: Vendor_Key | null;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `DeleteVendor`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, DeleteVendorVariables } from '@dataconnect/generated';
|
||||
import { useDeleteVendor } from '@dataconnect/generated/react'
|
||||
|
||||
export default function DeleteVendorComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useDeleteVendor();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useDeleteVendor(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useDeleteVendor(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useDeleteVendor(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useDeleteVendor` Mutation requires an argument of type `DeleteVendorVariables`:
|
||||
const deleteVendorVars: DeleteVendorVariables = {
|
||||
id: ...,
|
||||
};
|
||||
mutation.mutate(deleteVendorVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ id: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(deleteVendorVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.vendor_delete);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
## CreateEvent
|
||||
You can execute the `CreateEvent` Mutation using the `UseMutationResult` object returned by the following Mutation hook function (which is defined in [dataconnect-generated/react/index.d.ts](./index.d.ts)):
|
||||
```javascript
|
||||
useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
```javascript
|
||||
useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
```
|
||||
|
||||
### Variables
|
||||
The `CreateEvent` Mutation requires an argument of type `CreateEventVariables`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
|
||||
```javascript
|
||||
export interface CreateEventVariables {
|
||||
eventName: string;
|
||||
isRecurring: boolean;
|
||||
recurrenceType?: RecurrenceType | null;
|
||||
businessId: UUIDString;
|
||||
vendorId?: UUIDString | null;
|
||||
status: EventStatus;
|
||||
date: TimestampString;
|
||||
shifts?: string | null;
|
||||
total?: number | null;
|
||||
requested?: number | null;
|
||||
assignedStaff?: string | null;
|
||||
}
|
||||
```
|
||||
### Return Type
|
||||
Recall that calling the `CreateEvent` Mutation hook function returns a `UseMutationResult` object. This object holds the state of your Mutation, including whether the Mutation is loading, has completed, or has succeeded/failed, among other things.
|
||||
|
||||
To check the status of a Mutation, use the `UseMutationResult.status` field. You can also check for pending / success / error status using the `UseMutationResult.isPending`, `UseMutationResult.isSuccess`, and `UseMutationResult.isError` fields.
|
||||
|
||||
To execute the Mutation, call `UseMutationResult.mutate()`. This function executes the Mutation, but does not return the data from the Mutation.
|
||||
|
||||
To access the data returned by a Mutation, use the `UseMutationResult.data` field. The data for the `CreateEvent` Mutation is of type `CreateEventData`, which is defined in [dataconnect-generated/index.d.ts](../index.d.ts). It has the following fields:
|
||||
```javascript
|
||||
export interface CreateEventData {
|
||||
event_insert: Event_Key;
|
||||
}
|
||||
```
|
||||
|
||||
To learn more about the `UseMutationResult` object, see the [TanStack React Query documentation](https://tanstack.com/query/v5/docs/framework/react/reference/useMutation).
|
||||
|
||||
### Using `CreateEvent`'s Mutation hook function
|
||||
|
||||
```javascript
|
||||
import { getDataConnect } from 'firebase/data-connect';
|
||||
import { connectorConfig, CreateEventVariables } from '@dataconnect/generated';
|
||||
import { useCreateEvent } from '@dataconnect/generated/react'
|
||||
|
||||
export default function CreateEventComponent() {
|
||||
// Call the Mutation hook function to get a `UseMutationResult` object which holds the state of your Mutation.
|
||||
const mutation = useCreateEvent();
|
||||
|
||||
// You can also pass in a `DataConnect` instance to the Mutation hook function.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const mutation = useCreateEvent(dataConnect);
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to the Mutation hook function.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(options);
|
||||
|
||||
// You can also pass both a `DataConnect` instance and a `useDataConnectMutationOptions` object.
|
||||
const dataConnect = getDataConnect(connectorConfig);
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
const mutation = useCreateEvent(dataConnect, options);
|
||||
|
||||
// After calling the Mutation hook function, you must call `UseMutationResult.mutate()` to execute the Mutation.
|
||||
// The `useCreateEvent` Mutation requires an argument of type `CreateEventVariables`:
|
||||
const createEventVars: CreateEventVariables = {
|
||||
eventName: ...,
|
||||
isRecurring: ...,
|
||||
recurrenceType: ..., // optional
|
||||
businessId: ...,
|
||||
vendorId: ..., // optional
|
||||
status: ...,
|
||||
date: ...,
|
||||
shifts: ..., // optional
|
||||
total: ..., // optional
|
||||
requested: ..., // optional
|
||||
assignedStaff: ..., // optional
|
||||
};
|
||||
mutation.mutate(createEventVars);
|
||||
// Variables can be defined inline as well.
|
||||
mutation.mutate({ eventName: ..., isRecurring: ..., recurrenceType: ..., businessId: ..., vendorId: ..., status: ..., date: ..., shifts: ..., total: ..., requested: ..., assignedStaff: ..., });
|
||||
|
||||
// You can also pass in a `useDataConnectMutationOptions` object to `UseMutationResult.mutate()`.
|
||||
const options = {
|
||||
onSuccess: () => { console.log('Mutation succeeded!'); }
|
||||
};
|
||||
mutation.mutate(createEventVars, options);
|
||||
|
||||
// Then, you can render your component dynamically based on the status of the Mutation.
|
||||
if (mutation.isPending) {
|
||||
return <div>Loading...</div>;
|
||||
}
|
||||
|
||||
if (mutation.isError) {
|
||||
return <div>Error: {mutation.error.message}</div>;
|
||||
}
|
||||
|
||||
// If the Mutation is successful, you can access the data returned using the `UseMutationResult.data` field.
|
||||
if (mutation.isSuccess) {
|
||||
console.log(mutation.data.event_insert);
|
||||
}
|
||||
return <div>Mutation execution {mutation.isSuccess ? 'successful' : 'failed'}!</div>;
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
import { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } from '../../esm/index.esm.js';
|
||||
import { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } from '../../esm/index.esm.js';
|
||||
import { validateArgs, CallerSdkTypeEnum } from 'firebase/data-connect';
|
||||
import { useDataConnectQuery, useDataConnectMutation, validateReactArgs } from '@tanstack-query-firebase/react/data-connect';
|
||||
|
||||
|
||||
export function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
export function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
export function useListEvents(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listEventsRef(dcInstance);
|
||||
@@ -43,3 +29,45 @@ export function useCreateVendor(dcOrOptions, options) {
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useUpdateVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return updateVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useDeleteVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return deleteVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
export function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useGetVendorById(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true);
|
||||
const ref = getVendorByIdRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
export function useFilterVendors(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false);
|
||||
const ref = filterVendorsRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
export function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
const { listVendorRef, createEventRef, listEventsRef, createStaffRef, listStaffRef, createVendorRef, connectorConfig } = require('../index.cjs.js');
|
||||
const { listEventsRef, createStaffRef, listStaffRef, createVendorRef, updateVendorRef, deleteVendorRef, listVendorRef, getVendorByIdRef, filterVendorsRef, createEventRef, connectorConfig } = require('../index.cjs.js');
|
||||
const { validateArgs, CallerSdkTypeEnum } = require('firebase/data-connect');
|
||||
const { useDataConnectQuery, useDataConnectMutation, validateReactArgs } = require('@tanstack-query-firebase/react/data-connect');
|
||||
|
||||
|
||||
exports.useListVendor = function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
exports.useListEvents = function useListEvents(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listEventsRef(dcInstance);
|
||||
@@ -43,3 +29,45 @@ exports.useCreateVendor = function useCreateVendor(dcOrOptions, options) {
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useUpdateVendor = function useUpdateVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return updateVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useDeleteVendor = function useDeleteVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return deleteVendorRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
|
||||
exports.useListVendor = function useListVendor(dcOrOptions, options) {
|
||||
const { dc: dcInstance, options: inputOpts } = validateReactArgs(connectorConfig, dcOrOptions, options);
|
||||
const ref = listVendorRef(dcInstance);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useGetVendorById = function useGetVendorById(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, true);
|
||||
const ref = getVendorByIdRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
exports.useFilterVendors = function useFilterVendors(dcOrVars, varsOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputVars, options: inputOpts } = validateReactArgs(connectorConfig, dcOrVars, varsOrOptions, options, true, false);
|
||||
const ref = filterVendorsRef(dcInstance, inputVars);
|
||||
return useDataConnectQuery(ref, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
exports.useCreateEvent = function useCreateEvent(dcOrOptions, options) {
|
||||
const { dc: dcInstance, vars: inputOpts } = validateArgs(connectorConfig, dcOrOptions, options);
|
||||
function refFactory(vars) {
|
||||
return createEventRef(dcInstance, vars);
|
||||
}
|
||||
return useDataConnectMutation(refFactory, inputOpts, CallerSdkTypeEnum.GeneratedReact);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,10 @@
|
||||
import { ListVendorData, CreateEventData, CreateEventVariables, ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables } from '../';
|
||||
import { ListEventsData, CreateStaffData, CreateStaffVariables, ListStaffData, CreateVendorData, CreateVendorVariables, UpdateVendorData, UpdateVendorVariables, DeleteVendorData, DeleteVendorVariables, ListVendorData, GetVendorByIdData, GetVendorByIdVariables, FilterVendorsData, FilterVendorsVariables, CreateEventData, CreateEventVariables } from '../';
|
||||
import { UseDataConnectQueryResult, useDataConnectQueryOptions, UseDataConnectMutationResult, useDataConnectMutationOptions} from '@tanstack-query-firebase/react/data-connect';
|
||||
import { UseQueryResult, UseMutationResult} from '@tanstack/react-query';
|
||||
import { DataConnect } from 'firebase/data-connect';
|
||||
import { FirebaseError } from 'firebase/app';
|
||||
|
||||
|
||||
export function useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
|
||||
export function useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
|
||||
export function useListEvents(options?: useDataConnectQueryOptions<ListEventsData>): UseDataConnectQueryResult<ListEventsData, undefined>;
|
||||
export function useListEvents(dc: DataConnect, options?: useDataConnectQueryOptions<ListEventsData>): UseDataConnectQueryResult<ListEventsData, undefined>;
|
||||
|
||||
@@ -22,3 +16,21 @@ export function useListStaff(dc: DataConnect, options?: useDataConnectQueryOptio
|
||||
|
||||
export function useCreateVendor(options?: useDataConnectMutationOptions<CreateVendorData, FirebaseError, CreateVendorVariables>): UseDataConnectMutationResult<CreateVendorData, CreateVendorVariables>;
|
||||
export function useCreateVendor(dc: DataConnect, options?: useDataConnectMutationOptions<CreateVendorData, FirebaseError, CreateVendorVariables>): UseDataConnectMutationResult<CreateVendorData, CreateVendorVariables>;
|
||||
|
||||
export function useUpdateVendor(options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
export function useUpdateVendor(dc: DataConnect, options?: useDataConnectMutationOptions<UpdateVendorData, FirebaseError, UpdateVendorVariables>): UseDataConnectMutationResult<UpdateVendorData, UpdateVendorVariables>;
|
||||
|
||||
export function useDeleteVendor(options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
export function useDeleteVendor(dc: DataConnect, options?: useDataConnectMutationOptions<DeleteVendorData, FirebaseError, DeleteVendorVariables>): UseDataConnectMutationResult<DeleteVendorData, DeleteVendorVariables>;
|
||||
|
||||
export function useListVendor(options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
export function useListVendor(dc: DataConnect, options?: useDataConnectQueryOptions<ListVendorData>): UseDataConnectQueryResult<ListVendorData, undefined>;
|
||||
|
||||
export function useGetVendorById(vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
export function useGetVendorById(dc: DataConnect, vars: GetVendorByIdVariables, options?: useDataConnectQueryOptions<GetVendorByIdData>): UseDataConnectQueryResult<GetVendorByIdData, GetVendorByIdVariables>;
|
||||
|
||||
export function useFilterVendors(vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
export function useFilterVendors(dc: DataConnect, vars?: FilterVendorsVariables, options?: useDataConnectQueryOptions<FilterVendorsData>): UseDataConnectQueryResult<FilterVendorsData, FilterVendorsVariables>;
|
||||
|
||||
export function useCreateEvent(options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
export function useCreateEvent(dc: DataConnect, options?: useDataConnectMutationOptions<CreateEventData, FirebaseError, CreateEventVariables>): UseDataConnectMutationResult<CreateEventData, CreateEventVariables>;
|
||||
|
||||
Reference in New Issue
Block a user