-
Notifications
You must be signed in to change notification settings - Fork 658
Description
Version
6.0.0
Operating System
macOS Darwin 25.3.0
Browser
Chrome (latest)
What are the steps to reproduce this bug?
- Create a singleton content model using
ModelFactorywith.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: []
});- Register it in
webiny.config.tsx:
<Api.Extension src={"@/extensions/siteConfig/AdminSettingsModel.ts"} />- Deploy the API:
yarn webiny deploy api - 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(notcreateManageSDL.js) to generate their GraphQL schema. ThecreateSingularSDLtype definition does not include thelivefield:
// 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:
createEntrySystemFieldsinnode_modules/@webiny/app-headless-cms-common/entries.graphql.jsconditionally excludeswbyAco_locationandmetafor singleton models (line 14-24), butlive { 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:
-
Client fix — in
app-headless-cms-common/entries.graphql.js, movelive { version }inside theif (!isSingletonModel)conditional block alongsidewbyAco_locationandmeta, OR -
API fix — in
api-headless-cms/graphql/schema/createSingularSDL.js, addlive: CmsEntryLiveto 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.