How to get other people with graphql?


#1

i wanan to generate an github report in my chat room,
then i has got my personal github access_token && githubApp,
how can i got other people info


#2

Hi @pengliheng,

I’m not sure I can help with a GitHub report in your chat room, but in general you can do something like this to execute a GraphQL query:

$ curl -H "Authorization: Bearer $GITHUB_PRODUCTION_TOKEN" -X POST -d '{"query":"query { viewer { login } }"}' https://api.github.com/graphql

Breaking that down piece by piece:

  1. curl is a command line utility to (among other things) make HTTP requests

  2. -H "Authorization: Bearer $GITHUB_PRODUCTION_TOKEN" is specifying an HTTP header named Authorization with a value of Bearer $GITHUB_PRODUCTION_TOKEN where $GITHUB_PRODUCTION_TOKEN is an OAuth token which can be generated here

  3. -X POST is specifying that we’d like to use the POST verb since we have to send data to the server

  4. -d '{"query":"query { viewer { login } }"}' is the actual data that we’re sending to the server. It’s a JSON formatted string with a key of query and a value of the GraphQL query that we’d like to make. In this case:

    query {
      viewer {
        login
      }
    }
    
  5. https://api.github.com/graphql is the HTTP endpoint that we’d like to send the request to

These are the main concepts behind a GraphQL query to the GitHub API. There are various libraries that can help you make these requests in your language of choice. Here is an example in Ruby.