I'm getting started on GraphQL with Apollo + Express and I see that the example adds a schema
name at the bottom of the typedefs:
let typeDefs = [`
type Query {
hello: String
}
schema {
query: Query
}`];
And after defining the resolvers it generates the schema with makeExecutableSchema
:
let schema = makeExecutableSchema({typeDefs, resolvers});
However if I remove the schema
part of the typedefs I can still use my endpoint normally, e.g.:
http://localhost:3000/graphql/?query={hello}
returns:
{"data":{"hello":"world"}}
But if I change the query part for something else, the server fails:
let typeDefs = [`
type Query {
hello: String
}
schema {
testquery: Query
}`];
GraphQLError: Syntax Error: Unexpected Name "testquery"
I have read through Apollo's tutorial pages and also the How To GraphQL tutorial for Node.js + GraphQL but can't find reference to that schema
part.
What is it used for?