Export `schema` and `root` so that we can use them in our app.js file.
Add below code snippet at the end of schema.js file.
It's time to run this query on the GraphQL Server that we just built (app.js file).
We will use `graphql-express` libaray to run GraphQL server on "/graphql" HTTP endpoint.
`graphiql: true` provides the GraphQL playground.
Head over to http://localhost:3000/graphql and you see the playground like this. ππ»
Let's try to run the query and see what we get.
And we are getting the data.
In our query, we requested for `name` and `age` fields of the `User` type.
Assuming you only need to fetch `age`, in GraphQL, you don't need to create a separate endpoint that you would have needed if you were working with REST API.
And with that being said, this is the end of this thread.
Follow @Rapid_API for more excellent content such as this one. ππ
β’ β’ β’
Missing some Tweet in this thread? You can try to
force a refresh