What plugin should I use to generate types for a server-side only library?

What plugin should I use to generate types for a server-side only library?


0

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, {})


Load 7 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *