Last active
February 15, 2018 08:39
-
-
Save peggyrayzis/1beeb43c2aa553db67c568241d5ef956 to your computer and use it in GitHub Desktop.
Apollo Boost query
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
import React from 'react'; | |
import { gql } from 'apollo-boost'; | |
import { Query } from 'react-apollo'; | |
const GET_DOG = gql` | |
query { | |
dog(breed: "bulldog") { | |
id | |
displayImage | |
} | |
} | |
` | |
export const App = () => ( | |
<Query query={GET_DOG}> | |
{({ loading, error, data }) => { | |
if (loading) return <div>Loading...</div>; | |
if (error) return <div>Error :(</div>; | |
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