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
graphql: resolvers/globals/update does not default args.data to {} when all fields are hidden and buildPolicyType reads globalThis.global #19067
While testing GraphQL globals with hidden fields on main (commit e442a3f), I ran into two small issues:
When all fields on a global are hidden, packages/graphql/src/schema/initGlobals.ts (line 110) omits the data argument from the update<Global> mutation, but packages/graphql/src/resolvers/globals/update.ts (line 42) still passes data: args.data without ?? {} (unlike resolvers/collections/create.ts and update.ts), causing updateOperationGlobal to throw MissingGlobalData.
In packages/graphql/src/schema/buildPoliciesType.ts (line 220), buildPolicyType computes globalTypeName using global?.graphQL?.name || slug where global is Node's globalThis.global instead of the destructured entity parameter (entity?.graphQL?.name || slug).
Happy to open a quick PR with a test in test/graphql if you want!
I investigated both issues and created a tested fix:
resolvers/globals/update.ts:
Defaulted data: (args.data ?? {}) as any (matching resolvers/collections/update.ts and create.ts), which ensures updateOperationGlobal receives an object when data is omitted or absent from the mutation arguments.
schema/buildPoliciesType.ts:
Changed global?.graphQL?.name || slug on line 220 to entity?.graphQL?.name || slug. In buildPolicyType, the parameter is named entity rather than global, so referencing global was resolving to Node's ambient globalThis.global object and always falling back to slug.
I also added a test in test/graphql/hidden-fields.int.spec.ts asserting that HiddenGlobalAccess and HiddenGlobalDocAccess use entity.graphQL.name.
Activity
ghazy2001 commentedon Oct 26, 2026
Hey team,
I investigated both issues and created a tested fix:
resolvers/globals/update.ts:Defaulted
data: (args.data ?? {}) as any(matchingresolvers/collections/update.tsandcreate.ts), which ensuresupdateOperationGlobalreceives an object whendatais omitted or absent from the mutation arguments.schema/buildPoliciesType.ts:Changed
global?.graphQL?.name || slugon line 220 toentity?.graphQL?.name || slug. InbuildPolicyType, the parameter is namedentityrather thanglobal, so referencingglobalwas resolving to Node's ambientglobalThis.globalobject and always falling back toslug.I also added a test in
test/graphql/hidden-fields.int.spec.tsasserting thatHiddenGlobalAccessandHiddenGlobalDocAccessuseentity.graphQL.name.PR is ready to review: ghazy2001/payload:fix/graphql-globals-update-missing-data
chore(graphql): default empty global mutation data
chore(graphql): honor global policy type names