You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(graphql): exclude hidden fields from mutation inputs - #18862
Fields configured with field-level hidden: true currently remain writable in generated GraphQL mutation inputs. Exclude them from collection create/update and global update inputs, including nested groups, arrays, rows, collapsibles, and named and unnamed tabs. Fields with only admin.hidden remain writable.
This extracts the general GraphQL fix identified during content branching review in #17878. It is based directly on main, uses no branching-specific names or exceptions, and tests the behavior without branching.
Changes
Share input-field reduction through a small helper at the top of buildMutationInputType.ts, so every reduction path applies the hidden-field filter.
Ignore hidden required children when deciding whether a group input is required.
Omit empty mutation inputs and empty access-policy field types; allow all-hidden collection mutations to run without a data argument.
Add regressions to the existing test/graphql fixtures for schema omission, rejected inputs without writes, visible and Admin-only hidden fields, internal defaults/hooks, and all-hidden structures.
Blocks retain their existing JSON scalar input contract: a hidden blocks field is omitted, but block child properties are not individually described or validated by the GraphQL input schema. Field access control is still required to restrict writes. Local API, REST, persistence, and access-control behavior are unchanged.
Compatibility and release treatment
Target the upcoming v4 release on main; do not backport this as an ordinary v3 patch. This changes accepted GraphQL inputs even without branching: clients submitting hidden fields will receive input-validation errors before a mutation executes. Regenerate client schemas/types and remove those values from mutation variables. If the intent is only to hide a field in the Admin Panel while keeping it writable through GraphQL, use admin.hidden instead of field-level hidden.
The existing field documentation's visibility wording should not be interpreted as write authorization. This fix controls generated GraphQL inputs; it does not introduce new REST or Local API write restrictions.
Test Plan
PAYLOAD_DATABASE=sqlite pnpm test:int graphql — 76 tests passed across six files using Node 24.15.0.
pnpm --filter @payloadcms/graphql build:types and build:swc — passed.
Focused oxlint, oxfmt --check, and git diff --check — passed (existing explicit-any warning in the collection update resolver).
Removing the hidden-field filter makes all three schema omission regressions fail as expected.
MongoDB integration tests could not start because the local MongoDB service is not running; integration verification used SQLite.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
📝 Walkthrough
GraphQL mutation input generation now omits hidden fields and omits empty policy-field objects. Collection create and update resolvers pass an empty object when mutation data is nullish. New integration tests cover hidden fields across collections, globals, and nested field structures.
Changes: Hidden-field GraphQL mutations
Layer / File(s)
Summary
Filter hidden fields in GraphQL schemas packages/graphql/src/schema/buildMutationInputType.ts, packages/graphql/src/schema/buildPoliciesType.ts, packages/graphql/src/utilities/groupOrTabHasRequiredSubfield.ts
Mutation input generation skips hidden fields and invokes applicable field builders once. Policy fields are included only when generated subfields are non-empty. Required-subfield checks exclude hidden entities and hidden direct subfields.
Default nullish mutation data packages/graphql/src/resolvers/collections/create.ts, packages/graphql/src/resolvers/collections/update.ts
Collection create and update resolvers pass an empty object to their operations when args.data is nullish.
Test configuration adds hidden collections, globals, and field fixtures. Integration tests cover schema omission, writes, defaults, hooks, and empty mutation data. Generated test types include the added entities and Lexical rich-text types.
The reviewed change is mergeable after normal checks; no unresolved issue was established.
Security architecture risk:🔵 Low · up to dbce3
The change narrows writable GraphQL inputs without demonstrating broader privileges or weaker authorization. Its main risks are client compatibility and configuration-specific empty-input behavior. No introduced security finding was established in the inspected paths.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The affected boundary is the generated GraphQL API for configured collections and globals using this builder. The inspected change narrows externally supplied field values; it does not add a service, credential, tenant-selection mechanism, or privileged operation.
Trust Boundaries and Controls
observed — GraphQL input validation limits submitted keys before resolver execution. Collection authorization and document selection remain in the underlying operations, including update access predicates tied to the requested ID. Hidden-field schema omission is therefore separate from write authorization.
Resilience and Maintainability Implications
observed — Empty collection mutations still enter the normal validation, default, hook, persistence, and transaction-cleanup pipeline. They are not inherently no-ops or idempotent: repeated authorized calls can execute application hooks again. The PR does not introduce a separate retry or recovery protocol.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 11 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title "fix(graphql): exclude hidden fields from mutation inputs" matches the main change. The changeset removes field-level hidden fields from generated GraphQL create, update, and global update i…
Description check
The description states that field-level hidden fields stay writable in GraphQL mutation inputs and describes the fix. It lists the changes to buildMutationInputType.ts, the hidden-required-child handl…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(graphql): exclude hidden fields from mutation inputs" matches the main change. The changeset removes field-level hidden fields from generated GraphQL create, update, and global update inputs, and the raw summary shows the mutation input builder and helper changes that do this. The title uses the conventional commit form and names the scope and effect.
Full details: Description check
Explanation
The description states that field-level hidden fields stay writable in GraphQL mutation inputs and describes the fix. It lists the changes to buildMutationInputType.ts, the hidden-required-child handling, empty input omission, and the new test fixtures, which match the raw summary. It also covers compatibility notes and the test plan.
✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
🛠️ Fix failing CI checks: 💡
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Non-blocking naming suggestion: I'd call reduceFieldsToSchemabuildMutationInputFields, since it builds the field definitions for a mutation input type. Within the helper, inputFields for the accumulator and initialInputFields for the optional starting value would make that clearer too. I'd keep fieldToSchemaMap and call the selected function buildFieldSchema.
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
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.
Written with AI
Description
Fields configured with field-level
hidden: truecurrently remain writable in generated GraphQL mutation inputs. Exclude them from collection create/update and global update inputs, including nested groups, arrays, rows, collapsibles, and named and unnamed tabs. Fields with onlyadmin.hiddenremain writable.This extracts the general GraphQL fix identified during content branching review in #17878. It is based directly on
main, uses no branching-specific names or exceptions, and tests the behavior without branching.Changes
buildMutationInputType.ts, so every reduction path applies the hidden-field filter.dataargument.test/graphqlfixtures for schema omission, rejected inputs without writes, visible and Admin-only hidden fields, internal defaults/hooks, and all-hidden structures.Blocks retain their existing JSON scalar input contract: a hidden blocks field is omitted, but block child properties are not individually described or validated by the GraphQL input schema. Field access control is still required to restrict writes. Local API, REST, persistence, and access-control behavior are unchanged.
Compatibility and release treatment
Target the upcoming v4 release on
main; do not backport this as an ordinary v3 patch. This changes accepted GraphQL inputs even without branching: clients submitting hidden fields will receive input-validation errors before a mutation executes. Regenerate client schemas/types and remove those values from mutation variables. If the intent is only to hide a field in the Admin Panel while keeping it writable through GraphQL, useadmin.hiddeninstead of field-levelhidden.The existing field documentation's visibility wording should not be interpreted as write authorization. This fix controls generated GraphQL inputs; it does not introduce new REST or Local API write restrictions.
Test Plan
PAYLOAD_DATABASE=sqlite pnpm test:int graphql— 76 tests passed across six files using Node 24.15.0.pnpm --filter @payloadcms/graphql build:typesandbuild:swc— passed.oxlint,oxfmt --check, andgit diff --check— passed (existing explicit-any warning in the collection update resolver).