Graphql-code-generator: Failed to load schema

Created on 16 Jul 2020  路  11Comments  路  Source: dotansimha/graphql-code-generator

I've faced with issue when I can鈥檛 load schema from our graphql server.
In the same time I can work with online playground without any problem.

Screen Shot 2020-07-16 at 19 58 57

this is my config:
```overwrite: true
schema:

Also I se this message in the trace.
Could not obtain introspection result, received: "Object reference not set to an instance of an object."

looks like the problem with graphql server, because I have no problem with another playground with the same config file... but I still don't understand how to debug it

is there a way to emulate fetch schema by cUrl for example?

waiting-for-answer

All 11 comments

Im having troubles reading my schema too. Try downloading it to a .json out of the graphql window
image

Despite that, i still cant get mine to read. it says it isnt valid... hmm

@tonypee I can download the schema from playground interface without problem. But loading from GraphQL-codegen still falling down.

@greenteamer Sorry for the late reply. This does appear to be a server-side issue in your case but it's not really clear what exactly has gone wrong since that's a pretty generic message we're getting from the server.

FWIW, here's the curl equivalent of the introspection query codegen is sending:

curl -X POST -H "Content-Type: application/json" -H "authorization: api-key" --data '{"query": "query IntrospectionQuery { __schema { queryType { name } mutationType { name } subscriptionType { name } types { ...FullType } directives { name description locations args { ...InputValue } } } } fragment FullType on __Type { kind name description fields(includeDeprecated: true) { name description args { ...InputValue } type { ...TypeRef } isDeprecated deprecationReason } inputFields { ...InputValue } interfaces { ...TypeRef } enumValues(includeDeprecated: true) { name description isDeprecated deprecationReason } possibleTypes { ...TypeRef } } fragment InputValue on __InputValue { name description type { ...TypeRef } defaultValue } fragment TypeRef on __Type { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name ofType { kind name } } } } } } } }"}' "https://myserver.com/reportings/graphql"

@tonypee Please share your config if you still need help debugging.

Ill make a seperate ticket - 2 mins!

@greenteamer any update? :)

@danielrearden thank's a lot! I will try soon!

Closing for now. @greenteamer if you are still having issues, let me know and I'll reopen.

Greetings I am having problems with downloading too. My server does not check for the form authorization: prefix token, it just reads jwt: token and I am not able to make it work with config as it is below. Thank you.

overwrite: true
schema: 
  - "my_endpoint":
    headers:
      jwt: my_token
documents: "src/**/*.graphql"
generates:
  src/generated/graphql.ts:
    plugins:
      - "typescript"
      - "typescript-operations"
      - "typescript-apollo-angular"
      - "typescript-graphql-files-modules"

@UlisesAC4 you have an indentation issue with your YAML:

overwrite: true
schema: 
  - "my_endpoint":
        headers:
          jwt: my_token

@dotansimha thank you for this, now everything is fine!

Was this page helpful?
0 / 5 - 0 ratings