1

I'm having a problem with generating TS typings for my graphql schema. The problem is that since I've already imported the typings while they existed, regenerating them does not work as it complains that the generated typings module does not exist (duh). The following is my codegen config:

require:
  - ts-node/register/transpile-only
overwrite: true
schema: src/schema.ts
documents: null
generates:
  src/__generated__/types.ts:
    config:
      scalars:
        DateTime: Date
      typesPrefix: GQL
    plugins:
      - "typescript"
      - "typescript-resolvers"

I import types from resolvers like:

import { GQLMutationResolvers } from '../../../__generated__/types"

which it cannot find, while trying to generate the types. What do I need to change about my approach for this to work? Any help is appreciated!

rosengrenen
  • 731
  • 6
  • 21
  • Solved it by writing my own script that combines all schema files from my modules (graphql-modules) and generates the types using graphql-codegen, which then outputs the types into the file. This way I can avoid ever importing the resolvers before the types have been generated – rosengrenen Oct 04 '19 at 08:29

0 Answers0