Error Retrieving GitHub API v4 Schema
See original GitHub issueI’m having issues retrieving GitHub’s GraphQL schema using the following configuration:
{
"schema": {
"request": {
"url": "https://api.github.com/graphql",
"method": "GET",
"postIntrospectionQuery": false,
"options": {
"headers": {
"authorization": "bearer xxx"
}
}
}
},
"endpoints" : [
{
"name": "GitHub v4",
"url": "https://api.github.com/graphql",
"options" : {
"headers": {
"authorization": "bearer xxx"
}
}
}
]
}
Creating a .graphql
allows me to perform queries just fine, but I get this error when trying to get the schema:
Error loading schema from 'https://api.github.com/graphql' Response {
statusCode: 403,
headers:
{ 'cache-control': 'no-cache',
connection: 'close',
'content-type': 'text/html' },
body: <Buffer 52 65 71 75 65 73 74 20 66 6f 72 62 69 64 64 65 6e 20 62 79 20 61 64 6d 69 6e 69 73 74 72 61 74 69 76 65 20 72 75 6c 65 73 2e 20 50 6c 65 61 73 65 20 ... >,
url: undefined } { url: 'https://api.github.com/graphql',
method: 'GET',
postIntrospectionQuery: false,
options:
{ headers:
{ authorization: 'bearer xxx',
'Content-Length': 0,
'Accept-Encoding': 'gzip,deflate' } } }
Status code 403 is an authentication response, which leads me to believe that the request is not being sent with the right headers. The GitHub documentation says that all I need to do is sent a GET request to the GraphQL endpoint to get the schema. To get around the error above I curl the schema into a file:
curl -H "Authorization: bearer xxx" https://api.github.com/graphql > graphql.schema.json
Then I change graphql.config.json
to use that file and that works beautifully:
{
"schema": {
"file": "graphql.schema.json",
},
...
}
I might be doing things wrong, but there’s no good way for me to debug and figure out where the request is going awry so that I can provide better debugging information.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:5
Top GitHub Comments
The 2.0 beta-1 release now works with the GitHub API. Installation instructions at https://github.com/jimkyndemeyer/js-graphql-intellij-plugin/releases/tag/2.0.0-beta-1
Note the GitHub introspection result is not fully aligned with the GraphQL spec for default values, so follow the steps document in https://github.com/jimkyndemeyer/graphql-config-examples/tree/master/github-api-v4
Just got word from the GitHub dev team that they fixed the non-spec issues in their schema. I just introspected it using the plugin and it validates without errors 👍