Skip to content

Latest commit

 

History

History
39 lines (33 loc) · 1.08 KB

File metadata and controls

39 lines (33 loc) · 1.08 KB

Grafbase ⨯ Field Resolvers

This example shows how to extend a Grafbase Database @model with a custom field resolver — Read the guide

Getting Started

  1. Run npx degit grafbase/grafbase/examples/resolvers-field grafbase-with-resolvers-field to clone this example
  2. Change directory into the new folder cd grafbase-with-resolvers-field
  3. Run cp grafbase/.env.example grafbase/.env
  4. Open grafbase/.env in your code editor and provide your OpenWeather API Key
  5. Run npx grafbase dev to start local dev server with your schema
  6. Visit http://localhost:4000
  7. Populate your backend with a Place:
mutation {
  placeCreate(
    input: {
      name: "Grand Hotel Central"
      location: { latitude: 41.3849706, longitude: 2.1755767 }
    }
  ) {
    place {
      id
    }
  }
}
  1. Query for the place (using the id above) to get the current weather:
{
  place(by: { id: "..." }) {
    name
    weather
  }
}