graphql-java with graphiql integration problem

117 views
Skip to first unread message

Rafal Szczepankiewicz

unread,
Sep 15, 2016, 6:21:54 AM9/15/16
to graphql-java
In order to integrate graphiql with any graphql endpoint that endpoint must be able to process graphiql introspection query.

This is how query looks like:
"\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n types {\n ...FullType\n }\n directives {\n name\n description\n locations
\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n description\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n"

In order for graphql-java to support that query two changes must be done:
  1. Remove all \n from query
  2. Remove locations from query
While removing all \n seems like a reasonable thing to do (expressjs also does it), locations seems like a integration gap.
Locations describe place where directive can be used which is part of graphql spec for ex. http://facebook.github.io/graphql/#sec--skip

Introspection query response example from expressjs-graphiql containing locations:
"directives": [
        {
          "name": "include",
          "description": "Directs the executor to include this field or fragment only when the `if` argument is true.",
          "locations": [
            "FIELD",
            "FRAGMENT_SPREAD",
            "INLINE_FRAGMENT"
          ],
          "args": [
            {
              "name": "if",
              "description": "Included when true.",
              "type": {
                "kind": "NON_NULL",
                "name": null,
                "ofType": {
                  "kind": "SCALAR",
                  "name": "Boolean",
                  "ofType": null
                }
              },
              "defaultValue": null
            }
          ]
        },

Do you have plans to add support for it ? Right now this is the only thing preventing integration (without code change on either query or server side) between graphql-java endpoint with graphiql client.

Reply all
Reply to author
Forward
0 new messages