Skip to content

Instantly share code, notes, and snippets.

@unicodeveloper
Last active August 8, 2018 07:39
Show Gist options
  • Save unicodeveloper/a38dc65c9e2f13ca9e777993e718e745 to your computer and use it in GitHub Desktop.
Save unicodeveloper/a38dc65c9e2f13ca9e777993e718e745 to your computer and use it in GitHub Desktop.
const GET_DOG_PHOTO = gql`
query dog($breed: String!) {
dog(breed: $breed) {
id
displayImage
}
}`;
export const queryComponent = `const DogPhoto = ({ breed }) => (
<Query query={GET_DOG_PHOTO} variables={{ breed }}>
{({ loading, error, data }) => {
if (loading) return null;
if (error) return 'Error!';
return (
<img src={data.dog.displayImage} />
);
}}
</Query>
);`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment