/admin endpoint not working for me

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.

Mmmm, that’s weird. Could you please try doing this flow →

  1. set your X-Auth-Token header with the Admin Key as value
  2. set your url to point to the admin endpoint (e.g. → https://my.own.deployment/admin)
  3. run the query →
{
  getGQLSchema {
    schema
  }
}

I don’t know how to change the endpoint in slash but in my script I added the “X-Auth-Token” with the admin token and I still get the same response.

You are hitting a GraphQL endpoint, but that query does not appear available, hmm.

Introspect the endpoint to see what is available to query:

{
  __schema {
    queryType {
      name
      fields {
        name
      }
    }
  }
}

If you get "message": "Access Denied" then it is a problem with the Dg-Auth header token. Otherwise you should get:

{
  "data": {
    "__schema": {
      "queryType": {
        "name": "Query",
        "fields": [
          { 
            "name": "getGQLSchema"
          },
          ...
        ]
      }
    }
  }
}

Thanks a lot for your help!

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?

Thanks for the help!

Ok I did not realize that what I needed what

{
  getGQLSchema {
    generatedSchema
  }
}

This gave me exactly what I needed and resolved all the errores. Except for one error.
A schema MUST have a query` operation defined.

This is very weird because there is a type Query in the result of the generated schema.

I made an issue now on the github of the plugin.
A schema MUST have a ‘query’ operation defined Error. But I have type Query in my schema. · Issue #458 · jimkyndemeyer/js-graphql-intellij-plugin (github.com)