Graphql-code-generator: regression in schema generation error reporting

Created on 26 May 2020  路  4Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug
in upgrading from 1.13.5 to 1.15.0 I noticed that error reporting during schema generation became less clear. My server requires authorization to inspect, and the original error message if invalid auth was provided was

    Failed to load schema from ######/graphiql:

            Unable to download schema from remote: {
      "error": "Auth credentials are invalid",
      "error_code": "AUTH_INVALID_CREDENTIALS"
    }
            Error: Unable to download schema from remote: {
      "error": "Auth credentials are invalid",
      "error_code": "AUTH_INVALID_CREDENTIALS"
    }
        at UrlLoader.load (######/node_modules/@graphql-toolkit/url-loader/index.cjs.js:92:19)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
        at async loadFile (######/node_modules/@graphql-toolkit/core/index.cjs.js:78:24)
        at async ######/node_modules/@graphql-toolkit/core/index.cjs.js:481:24

            GraphQL Code Generator supports:
              - ES Modules and CommonJS exports (export as default or named export "schema")
              - Introspection JSON File
              - URL of GraphQL endpoint
              - Multiple files with type definitions (glob expression)
              - String in config file

            Try to use one of above options and run codegen again.
    Error: Failed to load schema
        at loadSchema (######/node_modules/@graphql-codegen/cli/bin.js:406:15)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
    Error: Failed to load schema
        at loadSchema (######/node_modules/@graphql-codegen/cli/bin.js:406:15)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)

after updating, the error message is

    Failed to load schema from ######/graphiql:

        Cannot read property '__schema' of undefined
        TypeError: Cannot read property '__schema' of undefined
    at getSchemaFromIntrospection (######/node_modules/@graphql-tools/wrap/index.cjs.js:960:35)
    at Object.introspectSchema (######/node_modules/@graphql-tools/wrap/index.cjs.js:983:12)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async UrlLoader.load (######/node_modules/@graphql-tools/url-loader/index.cjs.js:78:30)
    at async loadFile (######/node_modules/@graphql-tools/load/index.cjs.js:48:24)
    at async ######/node_modules/@graphql-tools/load/index.cjs.js:425:24

        GraphQL Code Generator supports:
          - ES Modules and CommonJS exports (export as default or named export "schema")
          - Introspection JSON File
          - URL of GraphQL endpoint
          - Multiple files with type definitions (glob expression)
          - String in config file

        Try to use one of above options and run codegen again.
    Error: Failed to load schema
        at loadSchema (######/node_modules/@graphql-codegen/cli/bin.js:406:15)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)
    Error: Failed to load schema
        at loadSchema (######/node_modules/@graphql-codegen/cli/bin.js:406:15)
        at processTicksAndRejections (internal/process/task_queues.js:97:5)

Expected behavior
Show the error message from the server to make it clear what the root cause is.

bug dependencies waiting-for-release

Most helpful comment

@dotansimha thanks for jumping on that so quickly!
confirmed that installing that version provides the auth errors again 馃帀

All 4 comments

Thank you for reporting it @hkasemir .
It's a bug with @graphql-tools/.... @ardatan can you please take a look? )

@hkasemir can you please try 1.15.1-alpha-1f2eeae3.9?

@dotansimha thanks for jumping on that so quickly!
confirmed that installing that version provides the auth errors again 馃帀

Fixed in v1.15.2

Was this page helpful?
0 / 5 - 0 ratings