Skip to content

fix(graphql): default args.data and fix buildPolicyType global name - #19155

Open
Vedant1442 wants to merge 1 commit into
payloadcms:mainfrom
Vedant1442:fix/graphql-globals-update-and-buildpolicies
Open

Vedant1442 wants to merge 1 commit into
payloadcms:mainfrom
Vedant1442:fix/graphql-globals-update-and-buildpolicies

Conversation

@Vedant1442

Copy link
Copy Markdown

Fixes #19067. Two small fixes: 1) globals update resolver now defaults args.data to {} (matching collections create/update) to avoid MissingGlobalData when all fields are hidden. 2) buildPolicyType uses the destructured entity instead of Node's global when computing globalTypeName.

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 3ec8ea7 and 19c1848.

Files selected for processing: 2
  • packages/graphql/src/resolvers/globals/update.ts
  • packages/graphql/src/schema/buildPoliciesType.ts
Files skipped from review as they are similar to previous changes: 2
  • packages/graphql/src/resolvers/globals/update.ts
  • packages/graphql/src/schema/buildPoliciesType.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Walkthrough

The GraphQL global update resolver now passes an empty object when args.data is nullish. Global policy type naming now uses the entity’s optional GraphQL name, with the existing slug fallback and suffix.

Changes: GraphQL global fixes

Layer / File(s) Summary
Global update and policy type corrections
packages/graphql/src/resolvers/globals/update.ts, packages/graphql/src/schema/buildPoliciesType.ts
The update resolver defaults nullish data to {} and includes added documentation. The policy type name uses entity instead of global, retaining the slug fallback and suffix. Added documentation describes buildPolicyType.

Priority: Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related PRs

Suggested reviewers: danribbens

Merge Risk: Minimal · up to 19c18

No merge-blocking issue is established for these GraphQL global fixes; merge after normal validation.

Security architecture risk: Low · up to 3ec8e

The changes are narrowly scoped. Updates without generated input now follow the existing authorization and update lifecycle, while policy type names use the configured global name. No authorization bypass was demonstrated, but these updates can still trigger writes, versions, and application hooks.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The newly successful omitted-data path is bounded by globals whose GraphQL mutations are enabled and whose schema has no generated update input. It can reach the ordinary write, version, and hook lifecycle for that configured global; it does not introduce caller-selected global identities or new service authority.

Security Findings and Attack Paths

  • inferred — No authorization bypass was demonstrated for the newly admitted empty update. Caller-controlled omission changes the data supplied to the existing operation, but does not remove global authorization or field processing. Deployment-specific policies can distinguish an empty object from missing data, so their behavior remains outside this conclusion.

Trust Boundaries and Controls

  • observed — The GraphQL mutation does not expose publishAllLocales or unpublishAllLocales. Within the existing operation, localized publication intent is checked against field access and the processed status value before publication handling.

Resilience and Maintainability Implications

  • observed — The existing operation initializes its transaction inside a try block, commits when it owns the transaction after writes and hooks finish, and invokes transaction cleanup on caught errors. This establishes the cleanup control flow, not atomic rollback of arbitrary application-hook side effects or every database configuration.
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies both changes: defaulting GraphQL global update data and correcting the global policy type name.
Description check Passed The description directly explains both changes and connects them to issue #19067.
Linked Issues check Passed Issue #19067 has two coding requirements. The update resolver now passes args.data ?? {} to updateOperationGlobal. buildPolicyType now computes the global name from `entity?.graphQL?.name || slu…
Out of Scope Changes check Passed The reported changes are limited to the two fixes in issue #19067. The added comments document the affected code and support the implementation. No unrelated production changes, tests, documentation, …
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Linked Issues check

Explanation

Issue #19067 has two coding requirements. The update resolver now passes args.data ?? {} to updateOperationGlobal. buildPolicyType now computes the global name from entity?.graphQL?.name || slug. These changes satisfy both requirements. The issue suggests a test but does not require one.

Full details: Out of Scope Changes check

Explanation

The reported changes are limited to the two fixes in issue #19067. The added comments document the affected code and support the implementation. No unrelated production changes, tests, documentation, or refactoring are identified.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches
🧪 Generate unit tests (beta)
  • 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.

@Vedant1442
Vedant1442 force-pushed the fix/graphql-globals-update-and-buildpolicies branch from 3ec8ea7 to 19c1848 Compare October 28, 2026 17:40

This branch has not been deployed

No deployments
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.

graphql: resolvers/globals/update does not default args.data to {} when all fields are hidden and buildPolicyType reads globalThis.global

1 participant