This example shows how to extend a Grafbase Database @model with a custom field resolver — Read the guide
- Run
npx degit grafbase/grafbase/examples/resolvers-field grafbase-with-resolvers-fieldto clone this example - Change directory into the new folder
cd grafbase-with-resolvers-field - Run
cp grafbase/.env.example grafbase/.env - Open
grafbase/.envin your code editor and provide your OpenWeather API Key - Run
npx grafbase devto start local dev server with your schema - Visit http://localhost:4000
- Populate your backend with a
Place:
mutation {
placeCreate(
input: {
name: "Grand Hotel Central"
location: { latitude: 41.3849706, longitude: 2.1755767 }
}
) {
place {
id
}
}
}- Query for the place (using the
idabove) to get the currentweather:
{
place(by: { id: "..." }) {
name
weather
}
}