[4.x]: Users field not appearing in GraphQL schema
What happened?
Description
Users fields are not appearing in GraphQL entry type schemas, even when they are properly configured in the field layout and GraphQL schema permissions are enabled. The field appears in the GraphiQL documentation explorer under the generic entries interface but not under specific entry type interfaces, and queries fail with "Cannot query field" errors.
Steps to reproduce
- Create a Channel section
- Create a Users field and add it to that Channel's field layout
- Enable the section in GraphQL schema
- Make a GraphQL query to retrieve entries from that section
Expected behavior
Entries should be returned with the Users field accessible and queryable.
GraphQL Query Example:
{
entries(section: "mySection") {
title
... on mySection_myEntryType_Entry {
myTextField # This works
myUsersField { # This fails
fullName
}
}
}
}
Actual behavior
The Users field cannot be queried and returns errors like:
{
"errors": [
{
"message": "Cannot query field \"[fieldHandle]\" on type \"[section]_[entryType]_Entry\".",
"extensions": {
"category": "graphql"
}
}
]
}
Craft CMS version
4.16.13
PHP version
8.0.2
Operating system and version
macOS 15.6.1 (24G90)
Database type and version
Postgres 13
Image driver and version
No response
Installed plugins and versions
- besteadfast/craft-preparse-field: ^2.1.2
- cooltronicpl/document-helpers: ^3.0.0
- craftcms/cms: ^4.16.13
- craftcms/element-api: ^4.2.0
- craftcms/redactor: ^3.1.0
- doublesecretagency/craft-cpcss: 2.6.0
- ether/tags: ^2.0.0
- mmikkel/incognito-field: ^1.3.0
- nystudio107/craft-seomatic: ^4.1.16
- verbb/super-table: ^3.0
- verbb/workflow: 2.0.15
- vlucas/phpdotenv: ^3.4.0
Hi, thanks for getting in touch! Are you on a Craft CMS Solo or Pro license?
Quick update: If you’re on a Solo license, there’s a bug there that won’t allow you to query for the one user you can have. I have raised a PR for that. If you’re on a Pro license, double-check that the schema you’re using allows for viewing users.
Hi!
Thanks for your answer. I think that was the problem. I've updated to PRO and now works as expected. It was confusing, as you mentioned, that I was able to use that field but then not be able to query from Graphql.
Everything working fine now.
Thanks a lot have a beautiful day and happy coding! ☀️
Thanks for the update. Glad you got it working!
I’ll keep this issue open until the PR I raised is merged and released.