2

The following GraphQL query runs perfectly fine in Github GraphQL Explorer:

$ cat GraphQL_query.graphql
query {
  __schema {
    types {
      name
      kind
      description
      fields {
        name
      }
    }
  }
}

however, when I send it via curl:

curl -H "Authorization: bearer token" -X POST -d "`cat GraphQL_query.graphql`" https://api.github.com/graphql

I'll get:

{
  "message": "Problems parsing JSON",
  "documentation_url": "https://developer.github.com/v4"
}

What's wrong? How can I make it works? Thx.

xpt
  • 20,363
  • 37
  • 127
  • 216
  • This Q/A helped me find a [better Github search approach](https://medium.com/@suntong001/query-github-graphql-9a4547d33bad), FYI. – xpt Mar 31 '18 at 20:05

1 Answers1

4

The curl syntax would look like this for that query:

$ curl -H "Authorization: Bearer $GITHUB_PRODUCTION_TOKEN" https://api.github.com/graphql -X POST -d '{"query":"query { __schema { types { name kind description fields { name } } } }","variables":"{}"}'
bswinnerton
  • 4,533
  • 8
  • 41
  • 56