Last active
August 8, 2018 07:39
-
-
Save unicodeveloper/a38dc65c9e2f13ca9e777993e718e745 to your computer and use it in GitHub Desktop.
This file contains 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 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