Graphql-tools: Stitching schema without Query

Created on 27 Feb 2018  路  3Comments  路  Source: ardatan/graphql-tools

I am trying to stitch a schema that only contains a Mutation type (email service) but mergeSchema fails.

Intended outcome

Trying to stitch a schema that only contains type Mutation (without a type Query) should successfully merge into other schemas.

Actual outcome

The stitching fails with TypeError: Cannot read property 'getFields' of null in mergeSchema.js

How to reproduce the issue

Try stitching a schema like:

  type Mutation {
    createEmail(body: String!): Boolean
  }
schema stitching

Most helpful comment

@jonbudd agreed... same issue with a Subscription only service, makes it difficult to create single purpose microservices without creating fake query fields

All 3 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfaproject picture alfaproject  路  4Comments

ghost picture ghost  路  3Comments

stubailo picture stubailo  路  3Comments

radiegtya picture radiegtya  路  5Comments

adamkl picture adamkl  路  3Comments