Difference between revisions of "GitHub-GraphQL"

From BITPlan Wiki
Jump to navigation Jump to search
Line 39: Line 39:
 
}
 
}
 
</source>
 
</source>
 +
 +
adding the authorization also did not work. So I tried:
 +
<source lang='bash'>
 +
curl -H "Authorization: bearer 524a..." -H "Accept: application/vnd.github.v4.idl" https://api.github.com/graphql -o githubschemav4.idl
 +
</source>
 +
which gives a strange json result with verbatim <nowiki>/n</nowiki> in it. At least this is closer to what I expected.

Revision as of 17:24, 16 March 2018

Trying to use the GitHub GraphQL API with GrapQL-Java i asked the following Stackoverflow question:

While waiting for an answer I found:

And therefore decided to download the MacOS package of npm from:

Which installed Node.js v8.10.0 and npm v5.6.0 on my system I could then install

npm install -g get-graphql-schema

after fixing the permission errors of the first attempt with

cd /usr/local/lib
sudo chmod g+w node_modules/
sudo chgrp staff node_modules/

Which lead to the error message

get-graphql-schema https://api.github.com/graphql > githubschema.graphql
TypeError: Cannot read property '__schema' of undefined
    at Object.buildClientSchema (/usr/local/lib/node_modules/get-graphql-schema/node_modules/graphql/utilities/buildClientSchema.js:48:43)
    at /usr/local/lib/node_modules/get-graphql-schema/dist/index.js:89:54
    at step (/usr/local/lib/node_modules/get-graphql-schema/dist/index.js:33:23)
    at Object.next (/usr/local/lib/node_modules/get-graphql-schema/dist/index.js:14:53)
    at fulfilled (/usr/local/lib/node_modules/get-graphql-schema/dist/index.js:5:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Trying https://api.github.com/graphql directly I get:

{
  "message": "This endpoint requires you to be authenticated.",
  "documentation_url": "https://developer.github.com/v3/#authentication"
}

adding the authorization also did not work. So I tried:

curl -H "Authorization: bearer 524a..." -H "Accept: application/vnd.github.v4.idl" https://api.github.com/graphql -o githubschemav4.idl

which gives a strange json result with verbatim /n in it. At least this is closer to what I expected.