Skip to content

Instantly share code, notes, and snippets.

@jbaxleyiii
Created October 18, 2017 15:02
Show Gist options
  • Select an option

  • Save jbaxleyiii/4e0bd210d042dceda19644a6910b463b to your computer and use it in GitHub Desktop.

Select an option

Save jbaxleyiii/4e0bd210d042dceda19644a6910b463b to your computer and use it in GitHub Desktop.
Rest Link
const USER_QUERY = gql`
query RestData($email: String!){
user(email: $email) @rest(route: '/users/email/:email', email: $email) {
id
firstName
friends @rest(route: '/users/friends/:id') @provides(vars: ['id']) {
firstName
}
}
`;
export default graphql(USER_QUERY)(({ data }) => {
if (data.loading) return <div>loading...</div>;
return (
<div>
<p>{data.user.firstName} has {data.user.friends.length} friends:</p>
<ul>
{data.user.friends.map(({ firstName }) => (
<li>{firstName}</li>
)}
</ul>
</div>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment