Skip to content

[FR] Can firebase-admin run data-connect generated queries and mutations #2823

@r-bt

Description

@r-bt

I'm trying to have a firebase function run a mutation for data connect. From reading here: https://firebase.google.com/docs/data-connect/admin-sdk this seems possible:

Since the Admin SDK operates with privileges, it can execute any of your queries and mutations regardless of access levels set using @auth directives, including the NO_ACCESS level.

However, it is not possible to pass the output of getDataConnect from firebase-admin/data-connect to a generated doMutationRef as the types don't match up.

For example when I try do this:

import { getDataConnect } from 'firebase-admin/data-connect';

const dataConnect = getDataConnect({
  serviceId: "PrepIt",
  location: "europe-west2",
});

import { createOrganisationRef} from 'dataconnect/generated'

createOrganisationRef(dataConnect, {
      organisationId: organisationID,
      userId: 'userId',
      role: 'Admin',
      isSupport: true,
});

it gives me the following error:

Argument of type 'import("/Users/richard/Documents/PrepIt/functions/node_modules/firebase-admin/lib/data-connect/data-connect").DataConnect' is not assignable to parameter of type 'import("/Users/richard/Documents/PrepIt/node_modules/@firebase/data-connect/dist/public").DataConnect'.
  Type 'DataConnect' is missing the following properties from type 'DataConnect': dataConnectOptions, isEmulator, getSettings, setInitialized, enableEmulatorts(2345)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions