dotansimha / dotansimha/graphql-code-generator-community
`typed-document-node` doesn't create export statement for all document fragments
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
### Which packages are impacted by your issue?
@graphql-codegen/typed-document-node
@graphql-codegen/near-operation-file-preset
### Describe the bug
1. When we create such document file:
```
import gql from 'graphql-tag';
export const CLIENT_FRAGMENT = gql`
fragment ClientFragment on Client {
id
email
}
`;
export const USER_FRAGMENT = gql`
fragment UserFragment on User {
id
email
client {
...ClientFragment
}
}
${CLIENT_FRAGMENT}
`;
```
2. then when we generate types, there is an error in `*.generated.ts` file.
Not all export fragment documents are created in `*.generated.ts` file.
It's interesting when we introduce such change:
```diff
export const USER_FRAGMENT = gql`
fragment UserFragment on User {
id
email
client {
- ...ClientFragment
}
}
- ${CLIENT_FRAGMENT}
`;
```
The export `ClientFragmentFragmentDoc` is created.
### Your Example Website or App
https://stackblitz.com/edit/github-eubitm
### Steps to Reproduce the Bug or Issue
1. Open the URL
2. run `npm run codegen`
3. open `test-fragment.document.generated.tsx`
4. you will see that there is an error:
> Cannot find name 'ClientFragmentFragmentDoc'. Did you mean 'UserFragmentFragmentDoc'?(2552)
5. the export document `ClientFragmentFragmentDoc` was not created
### Expected behavior
1. Open the URL
2. run `npm run codegen`
3. open `test-fragment.document.generated.tsx`
4. the export document `ClientFragmentFragmentDoc` exists
### Platform
- the newest versions of codegen
### Codegen Config File
```ts
const config: CodegenConfig = {
schema: 'schema.graphql',
documents: '**/*.document.ts',
generates: {
'types.ts': { plugins: ['typescript'] },
'/': {
preset: 'near-operation-file',
presetConfig: {
extension: '.generated.tsx',
baseTypesPath: 'types.ts',
},
plugins: ['typescript-operations', 'typed-document-node'],
config: {
documentMode: 'graphQLTag',
},
},
},
};
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.