0

According to Apollo docs

  • "Apollo Server 2 exports all of graphql-tools, so makeExecutableSchema and other functions can be imported directly from Apollo Server."
  • "Apollo Server is able to accept a schema that has been enabled by graphql-tools"

However, I've just noticed I can't directly import stitchSchemas from apollo-server (I've been using it from @graphql-tools/stitch), and am hours deep in problems that aren't making sense.

Does Apollo work with stitchSchemas or not?

Vok
  • 457
  • 5
  • 19

1 Answers1

1

Yes, you can use stitchSchemas with Apollo Server, but you should install the latest version of graphql-tools and import stitchSchemas from graphql-tools instead of apollo-server.

You can use the latest version of graphql-tools to build a GraphQLSchema object, whether through stitchSchemas, makeExecutableSchema or some other utility. You can then initialize ApolloServer using this schema:

const server = new ApolloServer({ schema })
Shubham A.
  • 2,446
  • 4
  • 36
  • 68
Daniel Rearden
  • 80,636
  • 11
  • 185
  • 183
  • Thanks. Does this include type merging? I was able to use the schema resulting from stitchSchemas before but each subschema would only return data from itself, any other fields were null. – Vok Jan 05 '21 at 18:58
  • That sounds like an issue with how you're using `stitchSchemas` in the first place. If you have a function that returns a GraphQLSchema object, that should work with Apollo, GraphQL Helix or pretty much any other GraphQL server library. – Daniel Rearden Jan 05 '21 at 19:37
  • Further testing confirms the type merging isn't happening on other platforms or clients either. The problem must be somewhere else. – Vok Jan 05 '21 at 20:35