Repository navigation
Open
Labels
Description
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:
- In
packages/graphql/src/schema/buildMutationInputType.ts(around line 322), thetabsfield handler callsconst requiresAtLeastOneField = groupOrTabHasRequiredSubfield(field)passing the outerTabsField(field, which hastabs: [...]rather thanfieldsorname) instead of the currenttab(Tab) being iterated. - 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 thegroupbranch 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
Reproduction Steps
- Define a collection with a
tabsfield containing a named tab (withname: 'meta') that has a direct subfield withrequired: true(for example{ name: 'title', type: 'text', required: true }). - Inspect the generated GraphQL
createmutation input schema for that collection. - Notice the
metatab input field is nullable instead ofGraphQLNonNull, becausebuildMutationInputType.tspassesfield(TabsField) instead oftab(Tab) togroupOrTabHasRequiredSubfield, andgroupOrTabHasRequiredSubfielddoes not checksubField.requiredon 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
ghazy2001 commentedon Oct 25, 2026
Opened fix with unit tests in #19057 passing \ ab\ to \groupOrTabHasRequiredSubfield\ and checking direct required subfields on named tabs identical to group fields.