I am trying to stitch a schema that only contains a Mutation type (email service) but mergeSchema fails.
Trying to stitch a schema that only contains type Mutation (without a type Query) should successfully merge into other schemas.
The stitching fails with TypeError: Cannot read property 'getFields' of null in mergeSchema.js
Try stitching a schema like:
type Mutation {
createEmail(body: String!): Boolean
}
My guess is that this is on purpose, to align with the official GraphQL spec: http://facebook.github.io/graphql/June2018/#sec-Root-Operation-Types
A schema defines the initial root operation type for each kind of operation it supports: query, mutation, and subscription; this determines the place in the type system where those operations begin.
The query root operation type must be provided and must be an Object type.
That is, a GraphQL API must have a Query type. I find this a pretty nonsensical part of the spec, especially now that subscriptions exist too; hopefully this changes in the future.
@jonbudd agreed... same issue with a Subscription only service, makes it difficult to create single purpose microservices without creating fake query fields
Can be tracked at spec at https://github.com/graphql/graphql-spec/issues/218 and https://github.com/graphql/graphql-spec/issues/490
Most helpful comment
@jonbudd agreed... same issue with a
Subscriptiononly service, makes it difficult to create single purpose microservices without creating fake query fields