Skip to content

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

Open

Description

@shafiktanbir

While testing GraphQL globals with hidden fields on main (commit e442a3f), I ran into two small issues:

  1. 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.
  2. 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!

Activity

  1. ghazy2001 commented on Oct 26, 2026

    @ghazy2001

    Hey team,

    I investigated both issues and created a tested fix:

    1. 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.
    2. 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.

    PR is ready to review: ghazy2001/payload:fix/graphql-globals-update-missing-data

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions