Describe the Bug
When using select: true in Payload CMS GraphQL queries while using MongoDB, block fields return null and cause a 500 error. This affects ALL blocks, regardless of their content.
Error:
Cannot return null for non-nullable field Content.text.
Without select: true |
With select: true |
 |
 |
Link to the code that reproduces this issue
https://github.com/jhb-dev/payload-graphql-select-blocks-issue
Reproduction Steps
- Clone the reproduction repository and run the development server with
pnpm dev
- Create test data:
curl -X POST http://localhost:3000/api/examples -H "Content-Type: application/json" \
-d '{"name":"Test","content":[{"blockType":"content","text":"Hello World"}]}'
- Open GraphQL Playground at http://localhost:3000/api/graphql-playground
- Run these queries:
Query WITHOUT select: true (works)
query ExamplesWithoutSelect {
Examples {
docs {
name
content {
... on Content {
text
}
}
}
}
}
Result: {"data":{"Examples":{"docs":[{"name":"Test","content":[{"text":"Hello World"}]}]}}}
Query WITH select: true (fails)
query ExamplesWithSelect {
Examples(select: true) {
docs {
name
content {
... on Content {
text
}
}
}
}
}
Result: 500 error, content: null
{
"errors": [{"message": "Something went wrong.", "path": ["Examples","docs",0,"content",0,"text"]}],
"data": {"Examples": {"docs": [{"name": "Test", "content": null}]}}
}
Which area(s) are affected?
area: graphql
Environment Info
payload: 3.74.0
@payloadcms/graphql: 3.74.0
next: 15.4.11
Describe the Bug
When using
select: truein Payload CMS GraphQL queries while using MongoDB, block fields returnnulland cause a 500 error. This affects ALL blocks, regardless of their content.Error:
select: trueselect: trueLink to the code that reproduces this issue
https://github.com/jhb-dev/payload-graphql-select-blocks-issue
Reproduction Steps
pnpm devQuery WITHOUT
select: true(works)Result:
{"data":{"Examples":{"docs":[{"name":"Test","content":[{"text":"Hello World"}]}]}}}Query WITH
select: true(fails)Result: 500 error,
content: null{ "errors": [{"message": "Something went wrong.", "path": ["Examples","docs",0,"content",0,"text"]}], "data": {"Examples": {"docs": [{"name": "Test", "content": null}]}} }Which area(s) are affected?
area: graphql
Environment Info