graphql-code-generator icon indicating copy to clipboard operation
graphql-code-generator copied to clipboard

Passthrough `onlyOperationTypes` and `onlyEnumTypes` in client-preset

Open nebbles opened this issue 1 year ago • 3 comments

Description

Passes through the onlyOperationTypes and onlyEnumTypes config options for the client preset.

onlyOperationTypes defaults to false however it would be useful focusing type generation on just the operations, reducing bundle size and developer error (a frequent one for us, building dependency on the wrong types).

As discussed in https://github.com/dotansimha/graphql-code-generator/discussions/8693

Type of change

New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • [ ] Test A
  • [ ] Test B

Test Environment:

  • OS:
  • @graphql-codegen/...:
  • NodeJS:

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...

nebbles avatar Sep 28 '24 21:09 nebbles

🦋 Changeset detected

Latest commit: 2c821b341f2f67e3cf4bd52c6fb6684e9aebc2f4

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/client-preset Minor

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

changeset-bot[bot] avatar Sep 28 '24 21:09 changeset-bot[bot]

Thanks @saihaj. Will make the changes requested! (I'm assuming changesets are generated with npx changeset)

nebbles avatar Oct 10 '24 20:10 nebbles

@saihaj I have made a minor adjustment to this PR to include passing through onlyEnumTypes.

This is the aim of my PR was achieved in https://github.com/dotansimha/graphql-code-generator/pull/10073 but via changing the under-the-hood behaviour of client-preset. As seen on that PR, there has been pushback as this has changed outputs for the preset in a way consumers had relied on.

I suggest that PR is reverted for the sake of those affected. Separately, this PR will allow those of us who want to reduce the size of the generated types to opt-in via these two configuration options.

nebbles avatar Oct 11 '24 07:10 nebbles