dotansimha/graphql-code-generator

Automatically exclude schema from documents

Open

#5.409 geöffnet am 16. Jan. 2021

Auf GitHub ansehen
 (1 Kommentar) (2 Reaktionen) (0 zugewiesene Personen)TypeScript (1.295 Forks)batch import
corehelp wantedkind/enhancement

Repository-Metriken

Stars
 (10.341 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 22T 9h) (53 gemergte PRs in 30 T)

Beschreibung

Describe the bug

My codegen configuration looks like this:

schema: ./src/graphql/schema/schema.graphql
documents: "**/*.graphql"

Running graphql-codegen causes the following error:

      Unable to find any GraphQL type definitions for the following pointers:
        
          - src/graphql/schema/schema.graphql

After quite a bit of playing around I realised why this is happening: graphql-codegen is trying to read either a query or mutation from src/graphql/schema/schema.graphql! 🤦

I have fixed this by changing my config to the following:

schema: ./src/graphql/schema/schema.graphql
documents:
  - "**/*.graphql"
  - "!src/graphql/schema/schema.graphql"

However, it seems really backwards that graphql-codegen would even attempt to parse the schema. It knows it's a schema! Let's just not parse it?!

Expected behavior

Don't fail if the documents glob includes the schema file.

Contributor Guide