I have a working codegen.yml
example using:
src/generated/graphql.tsx:
plugins:
- typescript
- typescript-operations
- typescript-react-apollo
that works great for our front end code making a tsx
final result used with react.
Over in my other project:
src/generated.ts:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-document-nodes"
I’ve replaced typescript-react-apollo
with typescript-document-nodes
and sometimes I can get it to produce stuff like:
export const FooFragment = gql`
fragment FooFragment on Foo {
id
name
description
}`;
export const GetFoos = gql`
query GetFoos {
groups {
edges {
node {
...FooFragment
}
}
totalCount
}
}
${FooFragment}`;
But it doesn’t work all the time! Like sometimes I run npx graphql-codegen
and I get those, sometimes not. My end goal is to be able to use urql
client and call client.query(GetFoos, {})