Expected Schema {...} to be a GraphQL schema

Viewed 3649

Trying to setup subscriptions through apollo, both on the backend and frontend. The error arises when trying to call subscribeToMore function of the Query component. Although it clearly says that the schema is not a GraphQL schema, was not able to find any issues.

I have a suspicion, since I am using merge-graphql-schemas to merge typeDefs and revolvers and passing the merged schema to SubscriptionServer it some how doesnt stitch it together with the Subscription Operation.

I have created a gist of all the related pieces.

TIA.

1 Answers

So I finally figured out the issue.

It indeed had to with merge-graphql-schemas library but due to my fault. After going through docs, that said

Beware that mergeResolvers is simply merging plain Javascript objects together. This means that you should be careful with Queries, Mutations or Subscriptions with naming conflicts.

Which also showed on console logging.

So it comes out that there are different options depending on the server implementation.

So making the schema using const schema = makeExecutableSchema({ typeDefs, resolvers }); helped resolve my problem.

Intially I tried using const schema = buildSchema(typeDefs); but for some reason it didnt stitch the resolvers and they stopped from firing.

Related