Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between buildSchema and makeExecutableSchema

Tags:

What is the difference between buildSchema from the graphql package and makeExecutableSchema from the graphql-tools package.

like image 292
Andreas Köberle Avatar asked Nov 19 '17 20:11

Andreas Köberle


1 Answers

Apart from the fact that they are from two different packages since buildSchema is from the official graphql-js package and makeExecutableSchema is from Apollo, they also do a slightly different things.

buildSchema builds a schema object from schema language. It takes just one big string of Type definitions as an argument.

makeExecutableSchema combines schema and resolvers to make executable schema. It's part of a graphql-tools package that makes it easier to use the schema language while also writing resolvers. So you define types and resolvers and pass them to makeExecutableSchema. You can pass an array of Schema definitions to it so that way you could merge multiple schemas together, modularize it.

See Apollo docs for graphql-tools to see their suggested way of building GraphQL servers.

like image 169
Andrija Ćeranić Avatar answered Sep 19 '22 08:09

Andrija Ćeranić