e03266008c
* form handler example: Update deps and fix build from dep update * Ran lint error fixers * Fixes errors that occur when commit occurs * Commit linter fixes
28 lines
552 B
JavaScript
28 lines
552 B
JavaScript
import { useGraphQL } from 'graphql-react'
|
|
|
|
export default () => {
|
|
const { loading, cacheValue = {} } = useGraphQL({
|
|
fetchOptionsOverride (options) {
|
|
options.url = 'https://graphql-pokemon.now.sh'
|
|
},
|
|
operation: {
|
|
query: `
|
|
{
|
|
pokemon(name: "Pikachu") {
|
|
name
|
|
image
|
|
}
|
|
}
|
|
`
|
|
}
|
|
})
|
|
|
|
const { data } = cacheValue
|
|
return data ? (
|
|
<img src={data.pokemon.image} alt={data.pokemon.name} />
|
|
) : loading ? (
|
|
<p>Loading…</p>
|
|
) : (
|
|
<p>Error!</p>
|
|
)
|
|
}
|