Created
February 19, 2019 17:44
-
-
Save hwillson/f6736cb5897e34bc434e2a28a19e1e8d to your computer and use it in GitHub Desktop.
Apollo Client - 2.5.0 Announcement Post - Manipulate Data
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
// 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 | |
} | |
} | |
`; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment