Skip to content

[Data Connect] Admin SDK bulk insert/insertMany fails to serialize enum values correctly (GraphQL coercion error) #9650

@samtsangbiz

Description

@samtsangbiz

[REQUIRED] Environment info

firebase-tools: 15.0.0 (latest as of December 2025)

Platform: macOS

firebase-admin version: 13.6.0 (latest as of November 2025)

Node.js version: 20.17 (or your version)

Tested in Data Connect emulator only.

[REQUIRED] Test case

Minimal schema (dataconnect/schema/schema.graphql):

enum TickerStatus {
  PRIMARY
  ACTIVE
  HISTORICAL
}

type Ticker @table {
  symbol: String!
  status: TickerStatus!
}

Minimal Node.js script:

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

admin.initializeApp();
// For emulator testing:
// process.env.DATA_CONNECT_EMULATOR_HOST = "127.0.0.1:9399";

const dc = getDataConnect({
  location: "us-west2", // or your location
  serviceId: "your-service-id",
});

async function testInsert() {
  try {
    await dc.insert("ticker", {
      symbol: "TEST",
      status: "PRIMARY", // string matching enum literal
    });
    console.log("Success");
  } catch (error) {
    console.error("Error:", error);
  }
}

testInsert();

[REQUIRED] Actual behavior
The operation fails with a GraphQL error:
textcannot represent non-enum value: PRIMARY
(or similar: "Expected type TickerStatus!, found "PRIMARY"")

Full error example (approximate):

JSON{
  "errors": [
    {
      "message": "Cannot represent non-enum value: \"PRIMARY\" as enum type TickerStatus!",
      "locations": [...],
      "path": [...]
    }
  ]
}
This indicates the SDK is serializing the enum value as an inline quoted string (status: "PRIMARY") in the generated mutation, which GraphQL cannot coerce to an enum literal when passed inline.
Workaround: Using executeGraphql with explicitly typed variables works:
TypeScriptconst mutation = `
  mutation InsertTicker($status: TickerStatus!) {
    ticker_insert(data: { symbol: "TEST", status: $status }) {
      symbol
    }
  }
`;

await dc.executeGraphql(mutation, {
  variables: { status: "PRIMARY" }
});

Thank you for looking into this! This limitation affects bulk data seeding for schemas using enums.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions