graphql-scalars icon indicating copy to clipboard operation
graphql-scalars copied to clipboard

Document how to specify schema for Code Generator

Open lorensr opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe.

When I look at the docs, it's missing schema field:

https://www.graphql-scalars.dev/docs/quick-start#graphql-code-generator-integration

When I try just:

schema: schema.graphql

where schema.graphql references eg PositiveInt, I get:

Something went wrong Failed to load schema for "./src/resolvers-types.ts"
        Failed to load schema from ./schema.graphql:

        Unknown type: "PositiveInt".
        Error: Unknown type: "PositiveInt".
    at getNamedType (/Users/me/gh/graphql/node_modules/graphql/utilities/extendSchema.js:427:13)

Describe the solution you'd like

Document what to do. Available formats:

https://www.graphql-code-generator.com/docs/config-reference/schema-field#available-formats

Describe alternatives you've considered

URL worked, but would prefer different solution: .graphql files, code files, or JS export.

lorensr avatar Apr 05 '22 05:04 lorensr

try this:

schema:
 - scalar PositiveInt
 - schema.graphql

also note, if you're using the typescript codegen plugin, you'll also need to map custom scalars to typescript types

acao avatar May 04 '22 22:05 acao