Skip to content

Singleton model Admin UI crashes with "Cannot query field live" #5012

@mjwlist

Description

@mjwlist

Version

6.0.0

Operating System

macOS Darwin 25.3.0

Browser

Chrome (latest)

What are the steps to reproduce this bug?

  1. Create a singleton content model using ModelFactory with .singleEntry():
import { ModelFactory } from "webiny/api/cms/model";

class AdminSettingsModelImpl implements ModelFactory.Interface {
    async execute(builder: ModelFactory.Builder) {
        return [
            builder
                .public({
                    modelId: "adminSettings",
                    name: "Admin Settings",
                    group: "ungrouped"
                })
                .fields(fields => ({
                    moduleCore: fields.boolean().renderer("switch").label("Core")
                }))
                .layout([["moduleCore"]])
                .titleFieldId("moduleCore")
                .singleEntry()
                .singularApiName("AdminSettings")
                .pluralApiName("AdminSettings")
        ];
    }
}

export const AdminSettingsModel = ModelFactory.createImplementation({
    implementation: AdminSettingsModelImpl,
    dependencies: []
});
  1. Register it in webiny.config.tsx:
<Api.Extension src={"@/extensions/siteConfig/AdminSettingsModel.ts"} />
  1. Deploy the API: yarn webiny deploy api
  2. Open the Admin UI and navigate to the singleton model

Alternatively create a new model in the admin UI as a singleton with a couple of basic fields. Save and navigate to the new singleton document content entry.

What is the expected behavior?

The singleton entry editor should load and display the form fields.

What do you see instead?

The Admin throws an unhandled error:

Uncaught (in promise) Error: GraphQL error: Cannot query field "live" on type "AdminSettings".

The error originates from SingletonContentEntryContext.js calling getSingletonEntry, which builds a GraphQL query that includes live { version } as a system field.

Additional information

The root cause appears to be a mismatch between the API-side schema and the Admin client query generation:

  • API side: Singleton models use createSingularSDL.js (not createManageSDL.js) to generate their GraphQL schema. The createSingularSDL type definition does not include the live field:
// node_modules/@webiny/api-headless-cms/graphql/schema/createSingularSDL.js, line 47-53
type ${singularName} {
    id: ID!
    entryId: String!
    ${onByMetaGqlFields}
    values: ${singularName}Values
}
  • Client side: createEntrySystemFields in node_modules/@webiny/app-headless-cms-common/entries.graphql.js conditionally excludes wbyAco_location and meta for singleton models (line 14-24), but live { version } (line 102-104) is unconditionally included outside the conditional block.

The schema selection happens in node_modules/@webiny/api-headless-cms/graphql/schema/schemaPlugins.js line 42:

if (model.tags?.includes(CMS_MODEL_SINGLETON_TAG)) {
    const singularType = type === "manage" ? "manage" : "read";
    const plugin = createCmsGraphQLSchemaPlugin({
        typeDefs: createSingularSDL({ ... }),
        // ...
    });
}

Possible solution

Either:

  1. Client fix — in app-headless-cms-common/entries.graphql.js, move live { version } inside the if (!isSingletonModel) conditional block alongside wbyAco_location and meta, OR

  2. API fix — in api-headless-cms/graphql/schema/createSingularSDL.js, add live: CmsEntryLive to the singleton type definition to match what the client expects.

Option 2 is probably more correct since live is a useful system field for singleton entries too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions