Skip to content

Named tabs with required subfields are not marked NonNull in GraphQL mutation inputs #19056

Open

Description

@shafiktanbir

Describe the Bug

While setting up GraphQL mutations on a collection that uses a named tabs field with required: true subfields inside the tab, the generated GraphQL mutation input type leaves the tab input nullable instead of wrapping it in GraphQLNonNull (unlike a group field with required subfields).

Looking at how tabs fields are built in packages/graphql:

  1. In packages/graphql/src/schema/buildMutationInputType.ts (around line 322), the tabs field handler calls const requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field) passing the outer TabsField (field, which has tabs: [...] rather than fields or name) instead of the current tab (Tab) being iterated.
  2. In packages/graphql/src/utilities/groupOrTabHasRequiredSubfield.ts (around line 21), the named tab branch (if ('fields' in entity && 'name' in entity)) only checks nested containers via (entity as Tab).fields.some((subField) => groupOrTabHasRequiredSubfield(subField)) without checking direct required subfields (fieldAffectsData(subField) && !subField.hidden && 'required' in subField && subField.required) the way the group branch above it does.

Should buildMutationInputType.ts pass tab to groupOrTabHasRequiredSubfield(tab) and have groupOrTabHasRequiredSubfield.ts check direct required subfields on named tabs just like group fields? I can put together a PR with a test if that sounds right.

Link to the code that reproduces this issue

https://github.com/payloadcms/payload/blob/main/packages/graphql/src/schema/buildMutationInputType.ts#L322

Reproduction Steps

  1. Define a collection with a tabs field containing a named tab (with name: 'meta') that has a direct subfield with required: true (for example { name: 'title', type: 'text', required: true }).
  2. Inspect the generated GraphQL create mutation input schema for that collection.
  3. Notice the meta tab input field is nullable instead of GraphQLNonNull, because buildMutationInputType.ts passes field (TabsField) instead of tab (Tab) to groupOrTabHasRequiredSubfield, and groupOrTabHasRequiredSubfield does not check subField.required on named tabs.

Which area(s) are affected?

area: graphql

Environment Info

Binaries:
  Node: 22.14.0
  pnpm: 10.6.0
Relevant Packages:
  payload: 3.79.0
  @payloadcms/graphql: 3.79.0
  next: 15.2.3
Operating System:
  Platform: linux

Activity

  1. added
    status: needs-triage
    validate-reproduction
    on Oct 25, 2026
  2. added and removed
    validate-reproduction
    on Oct 25, 2026
  3. ghazy2001 commented on Oct 25, 2026

    @ghazy2001

    Opened fix with unit tests in #19057 passing \ ab\ to \groupOrTabHasRequiredSubfield\ and checking direct required subfields on named tabs identical to group fields.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPayload OSSarea: graphqlstatus: needs-triagev3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions