question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Schema glob patterns not throwing errors

See original GitHub issue

Describe 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

  1. My GraphQL schema:
type Query {
  boop Boolean
}
type Query {
  beep: Boolean
}
  1. My GraphQL operations: n/a

  2. My codegen.yml config 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.8
  • graphql: 15.7.2
  • NodeJS: 14.8.1

Additional context

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

2reactions
ardatancommented, Nov 5, 2021

This popped out after we started handling globs inside loaders instead of @graphql-tools/load level. I think the behavior of CodeFileLoader is being used in GraphQLFileLoader as well because in CodeFileLoader, we ignore the files which we cannot load with require or extract SDL with tag-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;

  • Check existing tests and fix/update them to fail in this case
  • Fix this weird behavior
1reaction
charlypolycommented, Jul 29, 2022

@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.graphql does not get swallowed by the error in two.graphql.

Let us know if you still face this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found