GraphQL API endpoint is incorrect for Github Enterprise
heckler opened this issue · comments
My company's deployment of GHE does not have an "api.hostname/graphql" API endpoint - rather, it does not have the "api.domain" subdomain.
According to the documentation here the correct endpoint for the GraphQL API endpoint in Github Enterprise is https://hostname/api/graphql
I've patched dinghy locally to test using this endpoint and it works perfectly against GHE.
Note 1: if you select "Free, Pro & Team" from the dropdown selector at the top of the documentation page above, you'll see that indeed for githu.com the endpoint is https://api.github.com/graphql
as referenced in Dinghy, but for any hosted GHE instance, the documented endpoint is http(s)://[hostname]/api/graphql
Note 2: some GHE instances might ship with the "api.hostname" subdomain registered. My company's own GHE server does not though, as it's deployment follow the docs more strictly.
I guess we need a new setting, which is the hostname to use? The code already exists to use other hostnames, but as you point out, it assumes api.{hostname} will work. What should the setting be? Maybe defaults: enterprise_host: HOSTNAME.ORG
would be enough? And that setting would switch to the /api/graphql
form instead of the /graphql
form? I guess using that setting could also disable using features not available in Enterprise?
I have not fully digested this yet to be able to comment intelligently, but ... IF (and that's a big if) the public github's endpoint is always "api.github.com", and GHE is always "hostname/api", then maybe the code can infer that from checking whether the target is the public GH instance, or a private one.
Or, assume it is github.com as a default (most common use-case) and allow an override via cmdline or config file?
If adding an override option, maybe instead of calling it something_host, name it "api_root" or similar? (unless you mean to leave the /api/graphql part out of it, and expect only a true hostname to be provided?)
Thanks, I've added an api_root
setting on main. Can you give it a try?
Just tested api_root using the latest digest.py from master and it worked just fine, LGTM :)
OK, I've released this as part of dinghy 0.13.0.