Introspection of remote endpoint throws error without explicit "User-agent" header
See original GitHub issueI’m trying to perform an introspection and graphql SDL file generation locally using the following configuration:
{
"name": "Hasura Tutorial GraphQL Schema",
"schemaPath": "./schema.graphql",
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "https://hasura.io/learn/graphql",
"headers": {
"Authorization": "Bearer <token>"
},
"introspect": true
}
}
}
}
“token” above and surrounding brackets are replaced by my auth0 token. Using the above configuration works fine with @graphql-codegen so I know my token, etc. is all working fine. I would just prefer to use this plugin.
Link to Repo with Reproduction or Steps to Reproduce:
- Obtain auth token by logging into https://hasura.io/learn/graphql/graphiql
- Update .graphqlconfig per the above format along with token
- Restart project and get “perform introspection prompt…”; click it
- Get the following error: “GraphQL Introspection Error A valid schema could not be built using the introspection result: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $”
Expected behavior Connect to endpoint, perform introspection, and output SDL to “./schema.graphql” file
Version and Environment Details Operation system: MacOS v10.15.6 IDE name and version: Webstorm v2020.1.4 Plugin version: 2.5.0
Additional Context: I’m trying to step through a Hasura GraphQL with React+Typescript tutorial while replacing the use of the @graphql-codegen library with this plugin. The link to the tutorial is https://hasura.io/learn/graphql/typescript-react-apollo/queries/4-mapping-types
Thank you.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16
Top GitHub Comments
Ok, I just created a fresh project with nothing other than the standard React and Typescript libraries installed and tried it again. It was successful. My conclusion is there was something with another library I have installed in my other project that was causing the error. Thank you for all your help and sorry for raising an issue that was on my end.
I was getting this same error with just 1 remote server configured. I even added a “user-agent” header and it still failed. I changed the header to “User-Agent” and it started working.