First things first, let’s configure our GraphQL plugin for our Hapi server.

Now that there is a GraphQL endpoint we need a schema and some resolvers or this thing is gonna throw a fit when we start it up.

Cool, so now we have a schema to attach to our server and we can see that it defines some data points, but how do we actually connect those to our resolvers? If you look in the plugin you will see we pass our resolvers and schema to a function called makeExecutableSchema .

This is graphql-tools doing the heavy lifting for you. All you have to do is pass in a resolvers object that has a key for any Type in your schema that needs to resolve data from a source. In our case if we look at the highlights data point you will see that it resolves to an array of Video objects.

If we wanted to pull those videos from another endpoint we would need to make a resolver for it as such:

Since highlights is a key on our Match type, we have to have a Match property in our resolvers with a highlights property that is a resolver function.

Now we can query for a match and its highlights, even though one data source is a database and the other is an API call. This goes to show how flexible GraphQL can be when you need to handle complex data aggregation.