With that in mind, let’s break it down step by step.

makeExtendSchemaPlugin is our bread and butter, and gql allows us to write graphQL syntax right in a JS file. I’m using node-fetch here for simplicity’s sake. This is a backend application, and thus there is no access to window, and fetch won’t play nice.

This is where we name our new types. In this case we know the fields that come back from our external API call, so we map them all here. Next, we extend our query with a field name, and our new type.

Finally, we write our resolver. Using our field name from above, we pair it with a function call. In this case we reach out to our external API and fetch some data.

All that’s left to do here is fire up your Postgraphile application. In this use case, it’s done via a command on server start:

In the options parameter, we simply pass our new plugin to the appendPlugins key. As you can see, it’s an array that can take in any number of extensions.

Once this is done, you can see it in action in a graphiQL sandbox.

I hope this helps you make some great stuff!