Skip to content

GraphQL queries and fields for sites, sections, entry types, etc. - #20055

Merged
brandonkelly merged 4 commits into
5.12from
feature/gql-schema-components
Oct 21, 2026
Merged

brandonkelly merged 4 commits into
5.12from
feature/gql-schema-components

Conversation

@brandonkelly

@brandonkelly brandonkelly commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

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:

Component Top-level queries Element field
View sites (settings.sites:read) sites, site site on all elements
View sections (settings.sections:read) sections, section section on entries
View entry types (settings.entrytypes:read) entryTypes, entryType type on entries, entryTypes on sections
View volumes (settings.volumes:read) volumes, volume volume on assets
View user groups (settings.usergroups:read) userGroups, userGroup groups on users
View category groups (settings.categorygroups:read) categoryGroups, categoryGroup group on categories
View tag groups (settings.taggroups:read) tagGroups, tagGroup group on tags
{
  sites { handle language baseUrl }
  section(handle: "news") { name type entryTypes { handle } }
  entries(section: "news") {
    ... on EntryInterface {
      site { handle }
      section { handle }
      type { handle color }
    }
  }
}
  • The components appear at the top of their existing groups in the schema editor (Sites, Entries, Assets, Users, Categories, Tags). They're only listed when that kind of thing exists, and user groups aren't offered on Solo.
  • There are no mutation components; everything is read-only.
  • All queries accept id, uid, and handle arguments (single values or lists).
  • The new types only expose basic, non-sensitive details (ID, UID, name, handle, plus things like a section's type, an entry type's icon/color, and a site's language, base URL, and enabled status). No filesystem or other config details are exposed.
  • The new element field names (site, section, type, volume, groups, group) are all reserved field handles, so they can't collide with custom fields.
  • Top-level queries return everything of that kind, except disabled sites, which are only returned if the schema can query elements in them (so unlaunched sites aren't exposed by default). A user's groups field, 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, and craft\gql\types\CategoryGroup, EntryType, Section, Site, TagGroup, UserGroup, and Volume.

Tests are in tests/unit/gql/SettingsComponentsTest.php.

Related issues

🤖 Generated with Claude Code

brandonkelly and others added 4 commits October 21, 2026 07:11
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>
@brandonkelly
brandonkelly merged commit 60cf052 into 5.12 Oct 21, 2026
11 checks passed
@brandonkelly
brandonkelly deleted the feature/gql-schema-components branch October 21, 2026 09:43
@brandonkelly
brandonkelly requested a balanced review from Copilot November 2, 2026 23:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants