Consider a schema that contains only mutations:
type Mutation {
doSomething: Boolean
}
In such cases, it appears that an empty root Query object is being added to the results of the introspection queries:
{
"data": {
"__schema": {
"queryType": { "name": "Query" },
"mutationType": { "name": "Mutation" },
"subscriptionType": null,
"types": [
{
"kind": "OBJECT",
"name": "Query",
"description": "",
"fields": null,
"inputFields": [],
"interfaces": [],
"enumValues": null,
"possibleTypes": []
},
...
This is good, because (as I learned), the GraphQL spec requires a Query type but you can't define an empty type Query or type Query {} because all object types must have at least one field. Short of adding a fake field that would clutter the schema, having the introspection query tack on a Query object is a good idea!
HOWEVER, I'm getting an error in Postman:

This seems to be caused by "fields": null. As a workaround, I modified our code to patch that to be "fields": [] and the error goes away. (see hypermodeinc/modus#558)
I dug through the GraphQL Go Tools sources, but I really can't seem to find where the Query type is being added. Any ideas? Happy to send a PR if you can point me in the right direction. Thanks.
Consider a schema that contains only mutations:
In such cases, it appears that an empty root
Queryobject is being added to the results of the introspection queries:{ "data": { "__schema": { "queryType": { "name": "Query" }, "mutationType": { "name": "Mutation" }, "subscriptionType": null, "types": [ { "kind": "OBJECT", "name": "Query", "description": "", "fields": null, "inputFields": [], "interfaces": [], "enumValues": null, "possibleTypes": [] }, ...This is good, because (as I learned), the GraphQL spec requires a Query type but you can't define an empty
type Queryortype Query {}because all object types must have at least one field. Short of adding a fake field that would clutter the schema, having the introspection query tack on aQueryobject is a good idea!HOWEVER, I'm getting an error in Postman:

This seems to be caused by
"fields": null. As a workaround, I modified our code to patch that to be"fields": []and the error goes away. (see hypermodeinc/modus#558)I dug through the GraphQL Go Tools sources, but I really can't seem to find where the
Querytype is being added. Any ideas? Happy to send a PR if you can point me in the right direction. Thanks.