Repository navigation
GraphQL queries and fields for sites, sections, entry types, etc. - #20055
Merged
Merged
Conversation
Adds read-only GraphQL schema components for sites, sections, entry types, volumes, user groups, category groups, and tag groups. Each one enables top-level plural/singular queries (e.g. `sites`/`site`) and a field on the related element type (e.g. `site` on elements, `section` and `type` on entries). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Disabled sites are only returned by the `sites` query if the schema can query elements in them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Leaving the mocked entries service in place while fixtures unloaded caused garbage collection to delete user 1's elements_sites row, breaking later tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the permission-controlled GraphQL settings queries.
No open issues 🎉
What changed in this PR
Adds permission-controlled, read-only settings queries to Craft’s GraphQL API, allowing clients to retrieve configuration metadata directly or through related elements.
Changes:
- Adds singular and plural queries for seven settings types, with ID, UID, and handle filters.
- Adds related element fields, with visibility restrictions for disabled sites and user-group memberships.
- Registers schema-editor components and adds tests, translations, and release notes.
| File | Description |
|---|---|
| tests/unit/gql/SettingsComponentsTest.php | Tests queries, resolvers, permissions, and visibility restrictions. |
| src/translations/en/app.php | Adds schema-component labels and descriptions. |
| src/services/Gql.php | Registers settings queries and schema-editor components. |
| src/gql/types/Volume.php | Defines volume metadata fields. |
| src/gql/types/UserGroup.php | Defines user-group metadata fields. |
| src/gql/types/TagGroup.php | Defines tag-group metadata fields. |
| src/gql/types/Site.php | Defines site metadata and URL/status resolution. |
| src/gql/types/Section.php | Defines section metadata and conditional entry types. |
| src/gql/types/EntryType.php | Defines entry-type metadata and color resolution. |
| src/gql/types/elements/User.php | Resolves permission-filtered user groups. |
| src/gql/types/elements/Tag.php | Resolves a tag’s group. |
| src/gql/types/elements/Entry.php | Resolves an entry’s section and type. |
| src/gql/types/elements/Element.php | Resolves an element’s site. |
| src/gql/types/elements/Category.php | Resolves a category’s group. |
| src/gql/types/elements/Asset.php | Resolves an asset’s volume. |
| src/gql/types/CategoryGroup.php | Defines category-group metadata fields. |
| src/gql/queries/Settings.php | Implements settings queries, filters, and site visibility. |
| src/gql/interfaces/elements/User.php | Conditionally exposes user groups. |
| src/gql/interfaces/elements/Tag.php | Conditionally exposes tag groups. |
| src/gql/interfaces/elements/Entry.php | Conditionally exposes sections and entry types. |
| src/gql/interfaces/elements/Category.php | Conditionally exposes category groups. |
| src/gql/interfaces/elements/Asset.php | Conditionally exposes volumes. |
| src/gql/interfaces/Element.php | Conditionally exposes sites on elements. |
| CHANGELOG-5.12.md | Documents new GraphQL capabilities and classes. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds read-only GraphQL schema components for sites, sections, entry types, volumes, user groups, category groups, and tag groups. Each component enables top-level queries for that kind of thing, plus a field on the related element type:
settings.sites:read)sites,sitesiteon all elementssettings.sections:read)sections,sectionsectionon entriessettings.entrytypes:read)entryTypes,entryTypetypeon entries,entryTypeson sectionssettings.volumes:read)volumes,volumevolumeon assetssettings.usergroups:read)userGroups,userGroupgroupson userssettings.categorygroups:read)categoryGroups,categoryGroupgroupon categoriessettings.taggroups:read)tagGroups,tagGroupgroupon tags{ sites { handle language baseUrl } section(handle: "news") { name type entryTypes { handle } } entries(section: "news") { ... on EntryInterface { site { handle } section { handle } type { handle color } } } }id,uid, andhandlearguments (single values or lists).site,section,type,volume,groups,group) are all reserved field handles, so they can't collide with custom fields.groupsfield, however, only includes groups the schema can query users in (unless it can query all users), so membership in other groups isn't exposed.New classes:
craft\gql\queries\Settings, andcraft\gql\types\CategoryGroup,EntryType,Section,Site,TagGroup,UserGroup, andVolume.Tests are in
tests/unit/gql/SettingsComponentsTest.php.Related issues
section { … },site { … })sitesquery with site names and enabled statusesgroups, since users can belong to multiple groups)🤖 Generated with Claude Code