Skip to content

Conversation

@eddeee888
Copy link
Collaborator

Description

Fix Result fields being optional. In normal use cases, a requested field cannot be optional, just null.
There are some cases where a field can be optional:

  • When it is deferred
  • When it is conditional (with @skip or @include)

This PR fixes the issue by removing all related avoidOptionals for standard Result fields scenarios.
This makes it tighter and avoids the issue where users arbitrarily configure the result, which can lead to foot-gun situations

Related #10496

Type of change

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How Has This Been Tested?

  • Unit tests
  • Integration tests

@changeset-bot
Copy link

changeset-bot bot commented Dec 15, 2025

🦋 Changeset detected

Latest commit: 0e883fc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
@graphql-codegen/visitor-plugin-common Major
@graphql-codegen/typescript-operations Major
@graphql-codegen/client-preset Major
@graphql-codegen/typescript-document-nodes Patch
@graphql-codegen/gql-tag-operations Patch
@graphql-codegen/typescript-resolvers Patch
@graphql-codegen/typed-document-node Patch
@graphql-codegen/typescript Patch
@graphql-codegen/introspection Patch
@graphql-codegen/graphql-modules-preset Patch
@graphql-codegen/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@eddeee888 eddeee888 changed the title [typescript-operations] No optional Result fields, unless defer or conditional [typescript-operations] No optional Result fields, unless deferred or conditional Dec 17, 2025
@eddeee888 eddeee888 marked this pull request as ready for review December 17, 2025 12:23
@eddeee888 eddeee888 merged commit 0b26199 into master-next Dec 17, 2025
16 checks passed
@eddeee888 eddeee888 deleted the no-optional-fields branch December 17, 2025 12:23
eddeee888 added a commit that referenced this pull request Jan 6, 2026
… conditional (#10548)

* Fix types issues and put comments

* Handle avoidOptionals

* Update integration tests

* Add FIXME to pass test for now

* Add changeset
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.

2 participants