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.

Error Retrieving GitHub API v4 Schema

See original GitHub issue

I’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:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
jimkyndemeyercommented, Mar 21, 2019

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

0reactions
jimkyndemeyercommented, Sep 4, 2019

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 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

GraphQL API - GitHub Docs
The GitHub GraphQL API offers more precise and flexible queries than the GitHub ... retrieve data, and automate your workflows, use the GitHub...
Read more >
Troubleshooting - GitHub Docs
Learn how to resolve the most common problems people encounter in the REST API.
Read more >
ERR: Error retrieving Avro schema for id XX #1236 - GitHub
Hello everyone, I am new to Kafka and Schema Registry and currently, we have a problem with Schema Registry and not quite sure...
Read more >
Getting started with the REST API - GitHub Docs
Learn how to use the GitHub REST API.
Read more >
unable to retrieve the complete list of server APIs #6361 - GitHub
I am using it on k8 cluster version 1.13.9, same error is coming for deploying any stable chart. helm version version.BuildInfo{Version:"v3.0.0- ...
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