dotansimha / dotansimha/graphql-code-generator-community
Typescript Urql fails on documentMode external and does not apply typesPrefix properly
- Dominant language
- TypeScript
- Stars
- 137
- Forks
- 195
- Avg merge
- 6h 20m
- Merged PRs (30d)
- 16
Description
**Describe the bug**
documentMode external fails to generate properly
current workaround in most libraries is to add a typesPrefix when using documentMode: external
so we add typesPrefix `Operations.`
```
gen/operations/src/Urql.ts:
plugins:
- time
- typescript-urql
config:
documentMode: external
importDocumentNodeExternallyFrom: './ops'
typesPrefix: Operations.
```
Generates
```
import * as Operations from './ops';
import * as Urql from 'urql';
export type Omit = Pick>;
// Generated on 2022-02-16T12:00:20-08:00
export function useViewerQuery(
options?: Omit, 'query'>
) {
return Urql.useQuery({ query: ViewerDocument, ...options });
}
```
operations.ViewerQuery and Operations.ViewerQueryVariables are correct, by ViewerDocument is missing the prefix
To replicate, generate any external operations file and urql
....
Generation result without TypesPrefix, documentMode external, no operation types or document nodes resolve
```
import * as Operations from './ops';
import * as Urql from 'urql';
export type Omit = Pick>;
// Generated on 2022-02-16T12:07:28-08:00
export function useViewerQuery(
options?: Omit, 'query'>
) {
return Urql.useQuery({ query: ViewerDocument, ...options });
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.