dotansimha / dotansimha/graphql-code-generator
[relay-operation-optimizer] Fragment types are eliminated
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 23
Description
**Describe the bug**
Fragment types are eliminated when using the `relay-operation-optimizer` plugin.
**To Reproduce**
1. My GraphQL schema:
``
2. My GraphQL operations:
``
3. My `codegen.yml` config file:
``
**Expected behavior**
The fragments should be still there in their "optimized" form. E.g. you want to read a fragment from the apollo cache during runtime.
**Environment:**
- `@graphql-codegen/relay-optimizer-plugin@next`
- NodeJS: *
**Additional context (memo for me)**
I introduced this change here: https://github.com/n1ru4l/graphql-codegen-relay-plugins/commit/6578cbc1053bfe85f617130beb2853cb3ccf6461
However, I did not properly test it. I thought that skipping the `InlineFragmentsTransform` would be enough.
The correct solution seems to be the isolate of each fragment and it's inlined fragments into a single `GraphQLCompilerContext` and then apply the transforms. That way we receive all fragments with their inlined types.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.