Skip to content

Conversation

@eddeee888
Copy link
Collaborator

Description

Exact utility is only used to wrap variables types for operations (queries, mutations and subscriptions) if they exist in the document. Exact is never used for when there are fragments.

This is important to conditionally generate as users may use very strict tsconfig that will fail compiling if there are unused types.

This PR ensures Exact is conditionally generated: only generated when there are operations.

Related #10496

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit test

@changeset-bot
Copy link

changeset-bot bot commented Jan 13, 2026

🦋 Changeset detected

Latest commit: 42d82df

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

This PR includes changesets to release 1 package
Name Type
@graphql-codegen/typescript-operations 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

Comment on lines +102 to +117
mutation MakeAdmin {
makeUserAdmin(id: "100") {
...UserFragment
}
}
subscription UserChanges {
makeUserAdmin(id: "100") {
...UserFragment
}
}
fragment UserFragment on User {
id
role
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding these to make sure we test many things in the default test.
This gives more confidence overall.
e.g. in this PR I want to make sure Exact is used for mutation and subscription variables.

Comment on lines -715 to -724
type ResponseError {
error: ResponseErrorType!
}
enum ResponseErrorType {
NOT_FOUND
INPUT_VALIDATION_ERROR
FORBIDDEN_ERROR
UNEXPECTED_ERROR
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extraneous and never used in this test, so removed.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 13, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-codegen/cli 6.1.1-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/introspection 5.0.1-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/visitor-plugin-common 7.0.0-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-document-nodes 5.0.8-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/gql-tag-operations 5.1.3-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-operations 6.0.0-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript-resolvers 6.0.0-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/typed-document-node 6.1.6-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/typescript 6.0.0-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/client-preset 6.0.0-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎
@graphql-codegen/graphql-modules-preset 5.1.3-alpha-20260113134512-42d82dfa5bd5d9a89b285c06f6591dca2a782062 npm ↗︎ unpkg ↗︎

@eddeee888 eddeee888 merged commit 9a71231 into master-next Jan 13, 2026
19 checks passed
@eddeee888 eddeee888 deleted the only-generate-exact-if-has-operations branch January 13, 2026 13:52
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