Schema glob patterns not throwing errors
See original GitHub issueDescribe the bug
When doing typescript codegen, using schema as a glob pattern swallows errors, while a list of schema files works.
To Reproduce Create 2 schemas, 1 with a syntax error and the other without. Using a glob schema will swallow the syntax error and individually listing each schema file with correctly throw the syntax error.
In the example, in codegen.yml, the glob route is running by default and swallows the error.
Comment the glob way and uncomment out the list way, save the file, and it will correctly throw the error.
https://codesandbox.io/s/peaceful-snowflake-epsdc?file=/codegen.yml
- My GraphQL schema:
type Query {
boop Boolean
}
type Query {
beep: Boolean
}
-
My GraphQL operations: n/a
-
My
codegen.ymlconfig file:
# 1. Swallows errors and only outputs types for `two.gql`
schema: schemas/*.gql
# 2. Correctly throws syntax error for `one.gql`
#schema:
# - schemas/one.gql
# - schemas/two.gql
generates:
types.ts:
plugins:
- typescript
- typescript-operations
Expected behavior
Environment:
- OS: Linux
@graphql-codegen/cli: 2.2.1@graphql-codegen/typescript: 2.2.4@graphql-codegen/typescript-operations: 2.1.8graphql: 15.7.2- NodeJS: 14.8.1
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
buildSchema with glob in jest test throws duplicate type error
Describe the bug Using buildSchema with a list of imported modules works in normal app and jest tests. Using buildSchema with a glob...
Read more >flutter - yaml extension error ( Incorrect type. Expected "string ...
I've tried forcing the schema via # yaml-language-server: ... does not associate your file via glob pattern with an incorrect schema.
Read more >Configuring Jest
An array of glob patterns indicating a set of files for which coverage ... If the file specified by path is not found,...
Read more >Schemas - Dendron
Schemas. Summary. Schema help you apply consistent structure to all your notes. As you end up creating more notes, it can be hard...
Read more >Understanding schema errors | HESA
Schema errors prevent the validation being run in full because the file cannot be read. This means that errors cannot be traced to...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

This popped out after we started handling globs inside loaders instead of
@graphql-tools/loadlevel. I think the behavior of CodeFileLoader is being used in GraphQLFileLoader as well because in CodeFileLoader, we ignore the files which we cannot load withrequireor extract SDL withtag-pluck(otherwise you should need specifically define the files with GraphQL stuff). Also it is weird that we never notices in our bunch of unit tests. There are two things need to be done;@flippidippi, I created a reproduction repo with the latest versions of codegen packages: https://github.com/charlypoly/codegen-repros/tree/master/many-schema-files-swallow-errors
I cannot reproduce this issue; having an error in
one.graphqldoes not get swallowed by the error intwo.graphql.Let us know if you still face this issue.