dotansimha / dotansimha/graphql-code-generator-community

Fragments are imported but not used (because not spread anymore)

Open
#289 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
137
Forks
195
Avg merge
6h 20m
Merged PRs (30d)
16

Description

### Which packages are impacted by your issue?

_No response_

### Describe the bug

Related to: https://github.com/dotansimha/graphql-code-generator-community/issues/140#issuecomment-1448563349

When running the codegen, fragments are imported (like before), but not used anymore. This generated a TS error.

### Your Example Website or App

https://codesandbox.io/s/gql-code-generator-without-dedup-fragments-forked-35lp34?file=/src/user.fragment.generated.tsx

### Steps to Reproduce the Bug or Issue

1. Run yarn codegen
2. Open `src/user.fragment.generated.tsx`
3. See bug

### Expected behavior

I would expect the fragments to not be imported anymore.

### Screenshots or Videos

_No response_

### Platform

- OS: macOS
- NodeJS: 18.11.0
- `graphql` 16.6.0

"@graphql-codegen/add": "3.2.3",
"@graphql-codegen/cli": "2.16.4",
"@graphql-codegen/introspection": "2.2.3",
"@graphql-codegen/near-operation-file-preset": "2.5.0",
"@graphql-codegen/typed-document-node": "2.3.12",
"@graphql-codegen/typescript": "2.8.7",
"@graphql-codegen/typescript-operations": "2.5.12",

### Codegen Config File

schema: schema.graphql
documents: 'src/**/*.graphql'
generates:
src/:
preset: near-operation-file
presetConfig:
baseTypesPath: types.ts
extension: .generated.tsx
plugins:
- typescript
- typescript-operations
- typed-document-node
config:
onlyOperationTypes: true
preResolveTypes: true
inlineFragmentTypes: 'combine'

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