Skip to content

Comments

change documents type from array to object when no operations are found#10032

Merged
eddeee888 merged 3 commits intodotansimha:masterfrom
shota-tech:fix-documents-when-no-operations
Oct 26, 2025
Merged

change documents type from array to object when no operations are found#10032
eddeee888 merged 3 commits intodotansimha:masterfrom
shota-tech:fix-documents-when-no-operations

Conversation

@shota-tech
Copy link
Contributor

@shota-tech shota-tech commented Jul 8, 2024

Description

As mentioned in #10031, when using client preset, map of operations is an empty array when no operations are found. Because of this, noImplicitAny check does not pass.

This PR change the map from an empty array to an empty object.

Related #10031

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Screenshots/Sandbox (if appropriate/relevant):

Adding links to sandbox or providing screenshots can help us understand more about this PR and take action on it as appropriate

How Has This Been Tested?

  • Unit Test

Test Environment:

  • OS: MacOS
  • @graphql-codegen/...:
  • NodeJS: v18.17.1

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@changeset-bot
Copy link

changeset-bot bot commented Jul 8, 2024

🦋 Changeset detected

Latest commit: 7c781ff

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

This PR includes changesets to release 2 packages
Name Type
@graphql-codegen/gql-tag-operations Patch
@graphql-codegen/client-preset 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

@shota-tech shota-tech marked this pull request as ready for review July 8, 2024 01:41
@puku0x
Copy link

puku0x commented Oct 9, 2025

This PR is what I really needed 🎉
@dotansimha @eddeee888 What do you think of this change?

The problem is that documents is inferred as any[] which cause a type error under strict: true.
An alternative solution is to add type annotation to documents.

code.push('const documents: never[] = [];');

@eddeee888 eddeee888 merged commit 1debf51 into dotansimha:master Oct 26, 2025
17 checks passed
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.

3 participants