This README will guide you through the process of using the generated TypeScript SDK package for the connector default. It will also provide examples on how to use your generated SDK to call your Data Connect queries and mutations.
NOTE: This README is generated alongside the generated SDK. If you make changes to this file, they will be overwritten when the SDK is regenerated.
You can use this generated SDK by importing from the package @dataconnect/default-connector as shown below. Both CommonJS and ESM imports are supported.
You can also follow the instructions from the Data Connect documentation.
A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector default.
You can find more information about connectors in the Data Connect documentation.
import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig } from '@dataconnect/default-connector';
const dataConnect = getDataConnect(connectorConfig);By default, the connector will connect to the production service.
To connect to the emulator, you can use the following code. You can also follow the emulator instructions from the Data Connect documentation.
import { connectDataConnectEmulator, getDataConnect } from 'firebase/data-connect';
import { connectorConfig } from '@dataconnect/default-connector';
const dataConnect = getDataConnect(connectorConfig);
connectDataConnectEmulator(dataConnect, 'localhost', 9399);After it's initialized, you can call your Data Connect queries and mutations from your generated SDK.
There are two ways to execute a Data Connect Query using the generated Web SDK:
- Using a Query Reference function, which returns a
QueryRef- The
QueryRefcan be used as an argument toexecuteQuery(), which will execute the Query and return aQueryPromise
- The
- Using an action shortcut function, which returns a
QueryPromise- Calling the action shortcut function will execute the Query and return a
QueryPromise
- Calling the action shortcut function will execute the Query and return a
The following is true for both the action shortcut function and the QueryRef function:
- The
QueryPromisereturned will resolve to the result of the Query once it has finished executing - If the Query accepts arguments, both the action shortcut function and the
QueryReffunction accept a single argument: an object that contains all the required variables (and the optional variables) for the Query - Both functions can be called with or without passing in a
DataConnectinstance as an argument. If noDataConnectargument is passed in, then the generated SDK will callgetDataConnect(connectorConfig)behind the scenes for you.
Below are examples of how to use the default connector's generated functions to execute each query. You can also follow the examples from the Data Connect documentation.
You can execute the ListMovies query using the following action shortcut function, or by calling executeQuery() after calling the following QueryRef function, both of which are defined in default-connector/index.d.ts:
listMovies(): QueryPromise<ListMoviesData, undefined>;
listMoviesRef(): QueryRef<ListMoviesData, undefined>;You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
listMovies(dc: DataConnect): QueryPromise<ListMoviesData, undefined>;
listMoviesRef(dc: DataConnect): QueryRef<ListMoviesData, undefined>;The ListMovies query has no variables.
Recall that executing the ListMovies query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type ListMoviesData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface ListMoviesData {
movies: ({
id: UUIDString;
title: string;
imageUrl: string;
genre?: string | null;
} & Movie_Key)[];
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, listMovies } from '@dataconnect/default-connector';
// Call the `listMovies()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await listMovies();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await listMovies(dataConnect);
console.log(data.movies);
// Or, you can use the `Promise` API.
listMovies().then((response) => {
const data = response.data;
console.log(data.movies);
});import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, listMoviesRef } from '@dataconnect/default-connector';
// Call the `listMoviesRef()` function to get a reference to the query.
const ref = listMoviesRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = listMoviesRef(dataConnect);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.movies);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.movies);
});You can execute the GetMovieById query using the following action shortcut function, or by calling executeQuery() after calling the following QueryRef function, both of which are defined in default-connector/index.d.ts:
getMovieById(vars: GetMovieByIdVariables): QueryPromise<GetMovieByIdData, GetMovieByIdVariables>;
getMovieByIdRef(vars: GetMovieByIdVariables): QueryRef<GetMovieByIdData, GetMovieByIdVariables>;You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
getMovieById(dc: DataConnect, vars: GetMovieByIdVariables): QueryPromise<GetMovieByIdData, GetMovieByIdVariables>;
getMovieByIdRef(dc: DataConnect, vars: GetMovieByIdVariables): QueryRef<GetMovieByIdData, GetMovieByIdVariables>;The GetMovieById query requires an argument of type GetMovieByIdVariables, which is defined in default-connector/index.d.ts. It has the following fields:
export interface GetMovieByIdVariables {
id: UUIDString;
}Recall that executing the GetMovieById query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type GetMovieByIdData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface GetMovieByIdData {
movie?: {
id: UUIDString;
title: string;
imageUrl: string;
genre?: string | null;
} & Movie_Key;
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, getMovieById, GetMovieByIdVariables } from '@dataconnect/default-connector';
// The `GetMovieById` query requires an argument of type `GetMovieByIdVariables`:
const getMovieByIdVars: GetMovieByIdVariables = {
id: ...,
};
// Call the `getMovieById()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await getMovieById(getMovieByIdVars);
// Variables can be defined inline as well.
const { data } = await getMovieById({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await getMovieById(dataConnect, getMovieByIdVars);
console.log(data.movie);
// Or, you can use the `Promise` API.
getMovieById(getMovieByIdVars).then((response) => {
const data = response.data;
console.log(data.movie);
});import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, getMovieByIdRef, GetMovieByIdVariables } from '@dataconnect/default-connector';
// The `GetMovieById` query requires an argument of type `GetMovieByIdVariables`:
const getMovieByIdVars: GetMovieByIdVariables = {
id: ...,
};
// Call the `getMovieByIdRef()` function to get a reference to the query.
const ref = getMovieByIdRef(getMovieByIdVars);
// Variables can be defined inline as well.
const ref = getMovieByIdRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = getMovieByIdRef(dataConnect, getMovieByIdVars);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.movie);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.movie);
});You can execute the GetMeta query using the following action shortcut function, or by calling executeQuery() after calling the following QueryRef function, both of which are defined in default-connector/index.d.ts:
getMeta(): QueryPromise<GetMetaData, undefined>;
getMetaRef(): QueryRef<GetMetaData, undefined>;You can also pass in a DataConnect instance to the action shortcut function or QueryRef function.
getMeta(dc: DataConnect): QueryPromise<GetMetaData, undefined>;
getMetaRef(dc: DataConnect): QueryRef<GetMetaData, undefined>;The GetMeta query has no variables.
Recall that executing the GetMeta query returns a QueryPromise that resolves to an object with a data property.
The data property is an object of type GetMetaData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface GetMetaData {
ref: ({
id: UUIDString;
} & Meta_Key)[];
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, getMeta } from '@dataconnect/default-connector';
// Call the `getMeta()` function to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await getMeta();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await getMeta(dataConnect);
console.log(data.ref);
// Or, you can use the `Promise` API.
getMeta().then((response) => {
const data = response.data;
console.log(data.ref);
});import { getDataConnect, executeQuery } from 'firebase/data-connect';
import { connectorConfig, getMetaRef } from '@dataconnect/default-connector';
// Call the `getMetaRef()` function to get a reference to the query.
const ref = getMetaRef();
// You can also pass in a `DataConnect` instance to the `QueryRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = getMetaRef(dataConnect);
// Call `executeQuery()` on the reference to execute the query.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeQuery(ref);
console.log(data.ref);
// Or, you can use the `Promise` API.
executeQuery(ref).then((response) => {
const data = response.data;
console.log(data.ref);
});There are two ways to execute a Data Connect Mutation using the generated Web SDK:
- Using a Mutation Reference function, which returns a
MutationRef- The
MutationRefcan be used as an argument toexecuteMutation(), which will execute the Mutation and return aMutationPromise
- The
- Using an action shortcut function, which returns a
MutationPromise- Calling the action shortcut function will execute the Mutation and return a
MutationPromise
- Calling the action shortcut function will execute the Mutation and return a
The following is true for both the action shortcut function and the MutationRef function:
- The
MutationPromisereturned will resolve to the result of the Mutation once it has finished executing - If the Mutation accepts arguments, both the action shortcut function and the
MutationReffunction accept a single argument: an object that contains all the required variables (and the optional variables) for the Mutation - Both functions can be called with or without passing in a
DataConnectinstance as an argument. If noDataConnectargument is passed in, then the generated SDK will callgetDataConnect(connectorConfig)behind the scenes for you.
Below are examples of how to use the default connector's generated functions to execute each mutation. You can also follow the examples from the Data Connect documentation.
You can execute the CreateMovie mutation using the following action shortcut function, or by calling executeMutation() after calling the following MutationRef function, both of which are defined in default-connector/index.d.ts:
createMovie(vars: CreateMovieVariables): MutationPromise<CreateMovieData, CreateMovieVariables>;
createMovieRef(vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
createMovie(dc: DataConnect, vars: CreateMovieVariables): MutationPromise<CreateMovieData, CreateMovieVariables>;
createMovieRef(dc: DataConnect, vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;The CreateMovie mutation requires an argument of type CreateMovieVariables, which is defined in default-connector/index.d.ts. It has the following fields:
export interface CreateMovieVariables {
title: string;
genre: string;
imageUrl: string;
}Recall that executing the CreateMovie mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type CreateMovieData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface CreateMovieData {
movie_insert: Movie_Key;
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, createMovie, CreateMovieVariables } from '@dataconnect/default-connector';
// The `CreateMovie` mutation requires an argument of type `CreateMovieVariables`:
const createMovieVars: CreateMovieVariables = {
title: ...,
genre: ...,
imageUrl: ...,
};
// Call the `createMovie()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await createMovie(createMovieVars);
// Variables can be defined inline as well.
const { data } = await createMovie({ title: ..., genre: ..., imageUrl: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await createMovie(dataConnect, createMovieVars);
console.log(data.movie_insert);
// Or, you can use the `Promise` API.
createMovie(createMovieVars).then((response) => {
const data = response.data;
console.log(data.movie_insert);
});import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, createMovieRef, CreateMovieVariables } from '@dataconnect/default-connector';
// The `CreateMovie` mutation requires an argument of type `CreateMovieVariables`:
const createMovieVars: CreateMovieVariables = {
title: ...,
genre: ...,
imageUrl: ...,
};
// Call the `createMovieRef()` function to get a reference to the mutation.
const ref = createMovieRef(createMovieVars);
// Variables can be defined inline as well.
const ref = createMovieRef({ title: ..., genre: ..., imageUrl: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = createMovieRef(dataConnect, createMovieVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.movie_insert);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.movie_insert);
});You can execute the UpsertMovie mutation using the following action shortcut function, or by calling executeMutation() after calling the following MutationRef function, both of which are defined in default-connector/index.d.ts:
upsertMovie(vars: UpsertMovieVariables): MutationPromise<UpsertMovieData, UpsertMovieVariables>;
upsertMovieRef(vars: UpsertMovieVariables): MutationRef<UpsertMovieData, UpsertMovieVariables>;You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
upsertMovie(dc: DataConnect, vars: UpsertMovieVariables): MutationPromise<UpsertMovieData, UpsertMovieVariables>;
upsertMovieRef(dc: DataConnect, vars: UpsertMovieVariables): MutationRef<UpsertMovieData, UpsertMovieVariables>;The UpsertMovie mutation requires an argument of type UpsertMovieVariables, which is defined in default-connector/index.d.ts. It has the following fields:
export interface UpsertMovieVariables {
id: UUIDString;
title: string;
imageUrl: string;
}Recall that executing the UpsertMovie mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type UpsertMovieData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface UpsertMovieData {
movie_upsert: Movie_Key;
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, upsertMovie, UpsertMovieVariables } from '@dataconnect/default-connector';
// The `UpsertMovie` mutation requires an argument of type `UpsertMovieVariables`:
const upsertMovieVars: UpsertMovieVariables = {
id: ...,
title: ...,
imageUrl: ...,
};
// Call the `upsertMovie()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await upsertMovie(upsertMovieVars);
// Variables can be defined inline as well.
const { data } = await upsertMovie({ id: ..., title: ..., imageUrl: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await upsertMovie(dataConnect, upsertMovieVars);
console.log(data.movie_upsert);
// Or, you can use the `Promise` API.
upsertMovie(upsertMovieVars).then((response) => {
const data = response.data;
console.log(data.movie_upsert);
});import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, upsertMovieRef, UpsertMovieVariables } from '@dataconnect/default-connector';
// The `UpsertMovie` mutation requires an argument of type `UpsertMovieVariables`:
const upsertMovieVars: UpsertMovieVariables = {
id: ...,
title: ...,
imageUrl: ...,
};
// Call the `upsertMovieRef()` function to get a reference to the mutation.
const ref = upsertMovieRef(upsertMovieVars);
// Variables can be defined inline as well.
const ref = upsertMovieRef({ id: ..., title: ..., imageUrl: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = upsertMovieRef(dataConnect, upsertMovieVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.movie_upsert);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.movie_upsert);
});You can execute the DeleteMovie mutation using the following action shortcut function, or by calling executeMutation() after calling the following MutationRef function, both of which are defined in default-connector/index.d.ts:
deleteMovie(vars: DeleteMovieVariables): MutationPromise<DeleteMovieData, DeleteMovieVariables>;
deleteMovieRef(vars: DeleteMovieVariables): MutationRef<DeleteMovieData, DeleteMovieVariables>;You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
deleteMovie(dc: DataConnect, vars: DeleteMovieVariables): MutationPromise<DeleteMovieData, DeleteMovieVariables>;
deleteMovieRef(dc: DataConnect, vars: DeleteMovieVariables): MutationRef<DeleteMovieData, DeleteMovieVariables>;The DeleteMovie mutation requires an argument of type DeleteMovieVariables, which is defined in default-connector/index.d.ts. It has the following fields:
export interface DeleteMovieVariables {
id: UUIDString;
}Recall that executing the DeleteMovie mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type DeleteMovieData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface DeleteMovieData {
movie_delete?: Movie_Key | null;
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, deleteMovie, DeleteMovieVariables } from '@dataconnect/default-connector';
// The `DeleteMovie` mutation requires an argument of type `DeleteMovieVariables`:
const deleteMovieVars: DeleteMovieVariables = {
id: ...,
};
// Call the `deleteMovie()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await deleteMovie(deleteMovieVars);
// Variables can be defined inline as well.
const { data } = await deleteMovie({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await deleteMovie(dataConnect, deleteMovieVars);
console.log(data.movie_delete);
// Or, you can use the `Promise` API.
deleteMovie(deleteMovieVars).then((response) => {
const data = response.data;
console.log(data.movie_delete);
});import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, deleteMovieRef, DeleteMovieVariables } from '@dataconnect/default-connector';
// The `DeleteMovie` mutation requires an argument of type `DeleteMovieVariables`:
const deleteMovieVars: DeleteMovieVariables = {
id: ...,
};
// Call the `deleteMovieRef()` function to get a reference to the mutation.
const ref = deleteMovieRef(deleteMovieVars);
// Variables can be defined inline as well.
const ref = deleteMovieRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = deleteMovieRef(dataConnect, deleteMovieVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.movie_delete);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.movie_delete);
});You can execute the AddMeta mutation using the following action shortcut function, or by calling executeMutation() after calling the following MutationRef function, both of which are defined in default-connector/index.d.ts:
addMeta(): MutationPromise<AddMetaData, undefined>;
addMetaRef(): MutationRef<AddMetaData, undefined>;You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
addMeta(dc: DataConnect): MutationPromise<AddMetaData, undefined>;
addMetaRef(dc: DataConnect): MutationRef<AddMetaData, undefined>;The AddMeta mutation has no variables.
Recall that executing the AddMeta mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type AddMetaData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface AddMetaData {
ref: Meta_Key;
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, addMeta } from '@dataconnect/default-connector';
// Call the `addMeta()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await addMeta();
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await addMeta(dataConnect);
console.log(data.ref);
// Or, you can use the `Promise` API.
addMeta().then((response) => {
const data = response.data;
console.log(data.ref);
});import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, addMetaRef } from '@dataconnect/default-connector';
// Call the `addMetaRef()` function to get a reference to the mutation.
const ref = addMetaRef();
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = addMetaRef(dataConnect);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.ref);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.ref);
});You can execute the DeleteMeta mutation using the following action shortcut function, or by calling executeMutation() after calling the following MutationRef function, both of which are defined in default-connector/index.d.ts:
deleteMeta(vars: DeleteMetaVariables): MutationPromise<DeleteMetaData, DeleteMetaVariables>;
deleteMetaRef(vars: DeleteMetaVariables): MutationRef<DeleteMetaData, DeleteMetaVariables>;You can also pass in a DataConnect instance to the action shortcut function or MutationRef function.
deleteMeta(dc: DataConnect, vars: DeleteMetaVariables): MutationPromise<DeleteMetaData, DeleteMetaVariables>;
deleteMetaRef(dc: DataConnect, vars: DeleteMetaVariables): MutationRef<DeleteMetaData, DeleteMetaVariables>;The DeleteMeta mutation requires an argument of type DeleteMetaVariables, which is defined in default-connector/index.d.ts. It has the following fields:
export interface DeleteMetaVariables {
id: UUIDString;
}Recall that executing the DeleteMeta mutation returns a MutationPromise that resolves to an object with a data property.
The data property is an object of type DeleteMetaData, which is defined in default-connector/index.d.ts. It has the following fields:
export interface DeleteMetaData {
ref?: Meta_Key | null;
}import { getDataConnect } from 'firebase/data-connect';
import { connectorConfig, deleteMeta, DeleteMetaVariables } from '@dataconnect/default-connector';
// The `DeleteMeta` mutation requires an argument of type `DeleteMetaVariables`:
const deleteMetaVars: DeleteMetaVariables = {
id: ...,
};
// Call the `deleteMeta()` function to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await deleteMeta(deleteMetaVars);
// Variables can be defined inline as well.
const { data } = await deleteMeta({ id: ..., });
// You can also pass in a `DataConnect` instance to the action shortcut function.
const dataConnect = getDataConnect(connectorConfig);
const { data } = await deleteMeta(dataConnect, deleteMetaVars);
console.log(data.ref);
// Or, you can use the `Promise` API.
deleteMeta(deleteMetaVars).then((response) => {
const data = response.data;
console.log(data.ref);
});import { getDataConnect, executeMutation } from 'firebase/data-connect';
import { connectorConfig, deleteMetaRef, DeleteMetaVariables } from '@dataconnect/default-connector';
// The `DeleteMeta` mutation requires an argument of type `DeleteMetaVariables`:
const deleteMetaVars: DeleteMetaVariables = {
id: ...,
};
// Call the `deleteMetaRef()` function to get a reference to the mutation.
const ref = deleteMetaRef(deleteMetaVars);
// Variables can be defined inline as well.
const ref = deleteMetaRef({ id: ..., });
// You can also pass in a `DataConnect` instance to the `MutationRef` function.
const dataConnect = getDataConnect(connectorConfig);
const ref = deleteMetaRef(dataConnect, deleteMetaVars);
// Call `executeMutation()` on the reference to execute the mutation.
// You can use the `await` keyword to wait for the promise to resolve.
const { data } = await executeMutation(ref);
console.log(data.ref);
// Or, you can use the `Promise` API.
executeMutation(ref).then((response) => {
const data = response.data;
console.log(data.ref);
});