Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(typescript-operations): Add option 'combineFragmentNames' to combine only certain fragments when inlineFragmentTypes is 'inline' #10062

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Cellule
Copy link

@Cellule Cellule commented Jul 19, 2024

🚨 IMPORTANT: Please do not create a Pull Request without creating an issue first.

Any change needs to be discussed before proceeding. Failure to do so may result in the rejection of the pull request.

Description

The default 'inline' behavior for inlineFragmentTypes causes our project generated file to reach 12M
After some testing, 'combine' wasn't the right option for us either.
We really preferred 'inline' however we had 1 or 2 HUGE fragments used everywhere.
By not inlining those few fragments we could bring down the resulting generated file to ~3.5M
We've been working with a patch of the package for years now and I thought it be time to contribute back upstream in case others hit a similar issue.

Type of change

  • New feature (non-breaking change which adds functionality)

How Has This Been Tested?

Been running this in production for years now.
Wrote a unit test to show the usage.

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

I initially wanted to extend the type of inlineFragmentTypes to either 'inline' | 'combine' | 'mask' | string[] or 'inline' | 'combine' | 'mask' | { type: 'inline', except?: string[] }
These types are confusing and "hard-ish" to describe in json schema.
So I decided to make a new option instead with a runtime validation since I believe this option is broken when inlineFragmentTypes = 'mask'

Copy link

changeset-bot bot commented Jul 19, 2024

🦋 Changeset detected

Latest commit: 4ac6a1d

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

This PR includes changesets to release 9 packages
Name Type
@graphql-codegen/visitor-plugin-common Patch
@graphql-codegen/typescript-operations Patch
@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/graphql-modules-preset 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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant