Last active
February 20, 2019 01:16
-
-
Save hwillson/3d87b9b7353ca99d7da227e680c67692 to your computer and use it in GitHub Desktop.
Apollo Client - 2.5.0 Announcement Post - Resolve from API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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