I use Webstorm to write code and this editor comes with a graphql plugin. The plugin comes with its own introspection system but I decided to write a script instead that downloads the schema every time I open Webstorm so the plugin knows about it. Sadly I have been having issues with the /admin endpoint.
I try to make a request to the admin endpoint with the Dg-Auth header. I give that header an admin key I generated on slash.
The query I send is:
{
getGQLSchema {
schema
}
}
The response I get is:
{"response":{"errors":[{"message":"Query not supported"}],"status":200},"request":{"query":{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query",
"variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"getGQLSchema"},"arguments":[],"directives":[],"selectionSet":{"
kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"schema"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":59}}}}
Does anyone know why this happens? I used the exact same query as from the docs.
The problem was that I did not include a "Content-Type": "application/json", header. Also make sure you are sending a post request. I still get a lot of errors in the plugin however.
Apparently the webstorm graphql plugin is more strict. I also included the dgraph graphql fragment but it still complaints a lot.
Firstly it complains about hasInverse:
[Line number here] uses an illegal value for the argument ‘field’ on directive ‘hasInverse’. Argument value is of type ‘EnumValue’, expected a scalar. I get this error for every field that has a hasInverse.
And I get this a lot:
The object type ‘Typename here’ does not have a field ‘fieldname here’ required via interface
Maybe all these are warnings however but I was also hoping to get the generated schema for the generated graphql queries like getUser querryUser etc. Is there any way to get those so webstorm can know about them?