rsnext/examples/with-graphql-react/pages/index.js
Corbin Crutchley e03266008c form handler example: Update deps and fix build from dep update (#6732)
* 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
2019-03-27 16:12:45 -04:00

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>
)
}