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

Using `inlineFragmentTypes: 'combine'` and `mergeFragmentTypes: true` generates invalid imports/markup

Open lukereative opened this issue 1 year ago • 0 comments

Which packages are impacted by your issue?

@graphql-codegen/typescript-operations

Describe the bug

When using inlineFragmentTypes: 'combine' and mergeFragmentTypes: true together, if I create a fragment on an interface and then use it, the types that are generated are invalid.

It's trying to reference the types that are generated without mergeFragmentTypes i.e. UserDetails_UserWithEmail_Fragment when they have been merged into UserDetailsFragment so it's now invalid

Your Example Website or App

https://codesandbox.io/p/devbox/inline-fragment-types-issue-2wlt75

Steps to Reproduce the Bug or Issue

  1. Create a fragment on an interface
  2. Use it in two different queries for two different types
  3. Run codegen with inlineFragmentTypes: 'combine' and mergeFragmentTypes: true

Expected behavior

I would expect the generated types to reference the merged fragment types i.e. UserDetailsFragment not UserDetails_UserWithEmail_Fragment

Screenshots or Videos

No response

Platform

  • OS: macOS
  • NodeJS: 22.13.0
  • graphql version: 16.10.0
  • @graphql-codegen/* version(s):
    • "@graphql-codegen/typescript": "4.1.3",
    • "@graphql-codegen/typescript-operations": "4.4.1",

Codegen Config File

No response

Additional context

No response

lukereative avatar Feb 02 '25 21:02 lukereative