GraphQL Connector

Graeme CouparGraeme CouparJean MertzJean MertzJamie BartonJamie Barton
GraphQL Connector

Grafbase now supports connecting GraphQL APIs to the Edge Gateway!

Data no longer lives or belongs to only one source, but is often enhanced, indexed and retrieved across many service APIs and protocols.

From today, you can now unify your existing GraphQL APIs at the edge with Grafbase.

Let's see how easy it is to add Contentful using the new @graphql connector:

extend schema @graphql( name: "Contentful" url: "https://graphql.contentful.com/content/v1/spaces/{{ env.CONTENTFUL_SPACE_ID }}/environments/{{ env.CONTENTFUL_ENVIRONMENT }}" headers: [ { name: "Authorization", value: "Bearer {{ env.CONTENTFUL_API_KEY }}" } ] ) { query: Query }

That's it!

Grafbase will fetch all existing queries and mutations from the connected GraphQL schema and namespace them using the name you provided in the configuration.

query { contentful { blogPostCollection(limit: 5) { items { sys { id } title content { json } cover { url width height } } } } }

Grafbase also makes it easy to connect multiple remote APIs. Simply add another @graphql or @openapi directive:

extend schema @graphql( name: "Contentful" url: "https://graphql.contentful.com/content/v1/spaces/{{ env.CONTENTFUL_SPACE_ID }}/environments/{{ env.CONTENTFUL_ENVIRONMENT }}" headers: [ { name: "Authorization", value: "Bearer {{ env.CONTENTFUL_API_KEY }}" } ] ) @openapi( name: "OpenAI" schema: "https://raw.githubusercontent.com/openai/openai-openapi/master/openapi.yaml" headers: [ { name: "Authorization", value: "Bearer {{ env.OPENAI_API_KEY }}" } ] ) { query: Query }

As always, you can build locally using the Grafbase CLI.

npx grafbase init --template graphql-shopify-storefront

You can dive deeper with connectors by exploring the documentation.

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