Skip to content

Instantly share code, notes, and snippets.

@hwillson
Last active February 20, 2019 01:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hwillson/3d87b9b7353ca99d7da227e680c67692 to your computer and use it in GitHub Desktop.
Save hwillson/3d87b9b7353ca99d7da227e680c67692 to your computer and use it in GitHub Desktop.
Apollo Client - 2.5.0 Announcement Post - Resolve from API
const client = new ApolloClient({
// ...
resolvers: {
RentalCar: {
numberAvailable(car) => {
// Call into a separate car inventory tracking system,
// to get up to date car availibility.
return CarTracker.isCarAvailable(car.id);
},
},
},
});
// Query that when run will pull car details from the
// network, along with up to date car availibility
// calculated by the numberAvailable local resolver.
const RENTAL_CARS = gql`
query {
rentalCar {
id
make
model
year
numberAvailable @client
}
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment