Grafbase now supports extending remote GraphQL APIs with Edge Resolvers — learn more.
Get started by connecting a remote GraphQL API:
import { config, connector, g } from '@grafbase/sdk'
const contentful = connector.GraphQL('Contentful', {
url: g.env('CONTENTFUL_API_URL'),
headers: headers => {
headers.set('Authorization', `Bearer ${g.env('CONTENTFUL_API_KEY')}`)
},
})
g.datasource(contentful)
Then all that's left to do is to extend a type generated by the GraphQL connector that is resolved using your custom file:
import { g } from '@grafbase/sdk'
g.extend('ContentfulAsset', {
myField: {
args: { myArg: g.string().optional() },
returns: g.string().optional(),
resolver: 'file',
},
})
You can also use args
on fields for use inside the Edge Resolver:
export default function MyFieldResolver({ sys { id: assetId } }, { myArg }) {
return `${assetId} ${myArg}`
}
We'd also love to hear any of your feedback and ideas, so join us on Discord.