-
-
Save maka-io/764aaae61f223f8a89fdebed6d93c0d8 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
import gql from 'graphql-tag'; | |
import { Query } from 'react-apollo'; | |
const query = gql` | |
query SomeQuery { | |
foo { | |
bar | |
baz | |
} | |
} | |
`; | |
function MyComponent() { | |
return ( | |
<Query query={query}> | |
{(result) => { | |
if (result.loading) return <Loading />; | |
if (result.error) return <Error error={error} />; | |
const { data } = result; | |
return <h1>Hello {data.foo.bar} {data.foo.baz}!</h1>; | |
}) | |
</Query> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment