dotansimha / dotansimha/graphql-code-generator

Automatically exclude schema from documents

Open
#5,409 1 comment 2 reactions 0 assignees View on GitHub
core help wanted kind/enhancement
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

**Describe the bug**

My codegen configuration looks like this:

```yml
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:

```yml
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

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.