dotansimha / dotansimha/graphql-code-generator

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

Open
#10,276 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### 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_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.