Error: expected undefined to be a graphql schema.
if you are getting this error Error: Expected undefined to be a GraphQL schema
it's because You're not passing in a schema to your configuration for the /graphql endpoint. Property names are case-sensitive in javascript. Change this:
to this :
or make your variable lowercase and then do:
The simplest way to run a GraphQL API server is to use Express, a popular web application framework for Node.js. You will need to install two additional dependencies:
Let's modify our “hello world” example so that it's an API server rather than a script that runs a single query. We can use the 'express' module to run a webserver, and instead of executing a query directly with the graphql function, we can use the express-graphql library to mount a GraphQL API server on the “/graphql” HTTP endpoint:
You can run this GraphQL server with: