Skip to content

Instantly share code, notes, and snippets.

@hwillson
Created February 19, 2019 17:44
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/f6736cb5897e34bc434e2a28a19e1e8d to your computer and use it in GitHub Desktop.
Save hwillson/f6736cb5897e34bc434e2a28a19e1e8d to your computer and use it in GitHub Desktop.
Apollo Client - 2.5.0 Announcement Post - Manipulate Data
// Example ApolloClient config including a fullName resolver to
// combine first and last names.
const client = new ApolloClient({
// ...
resolvers: {
Customer: {
fullName(customer) => {
return `${customer.firstName} ${customer.lastName}`;
},
},
},
});
// Example customer details query including a customer full
// name string, which is calculated and returned by the
// fullName local resolver.
const CUSTOMER_DETAILS = gql`
query CustomerDetails($customerId: ID!) {
customer(id: $customerId) {
firstName
lastName
fullName @client
email
}
}
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment