Edge Resolvers

Jakub Wieczorek
Jakub Wieczorek
Marc Mettke
Marc Mettke
Jamie Barton
Jamie Barton
Edge Resolvers

Grafbase now supports Edge Resolvers!

No longer do you need to worry about scaling, configuring and deploying custom GraphQL servers.

Grafbase takes care of all of that, including support for local development using the CLI, branching, auth and more. Edge Resolvers give you the control and flexibility needed to deploy custom business logic to the edge.

Edge Resolvers are made up of two major components:

  • The field definition with @resolver directive
  • The resolver function implementation inside grafbase/resolvers

The Grafbase Edge Gateway glues together both components and deploys them to the edge.

Grafbase supports the following types of resolvers:

  • Query
  • Mutation
  • Field

You've probably seen how easy it is to get started with other GraphQL server frameworks. It's even easier with Grafbase:

Initialize a new Grafbase project using the CLI:

npx grafbase init

Inside grafbase/schema.graphql add the query hello:

extend type Query {
  hello(name: String): String! @resolver(name: "hello")

Add the following code to the file grafbase/resolvers/hello.js:

export default function Resolver(_, { name }) {
  return `Hello ${name || 'world'}!`

Next start the local development server:

npx grafbase dev

Finally execute the following GraphQL query:

query {
  hello(name: "Grafbase")

That's it!

You have custom code now running with Grafbase and will be automatically deployed to the edge when you push to GitHub.

Edge Resolvers don't just work at the query level, they also work with mutations, and fields of Grafbase Database models.

In this guide we'll explore fetching the current weather for places inside your Database using Field resolvers.

Weather API and Grafbase

You can dive deeper with Edge Resolvers by exploring the documentation.

We'd also love to hear any of your feedback and ideas, so join us on Discord.