mirror of
https://github.com/sergeyyarkov/next-apollo-graphql-setup.git
synced 2026-10-11 10:19:43 +03:00
17 lines
413 B
JavaScript
17 lines
413 B
JavaScript
import { useQuery } from '@apollo/react-hooks'
|
|
|
|
const Query = ({ children, query, id }) => {
|
|
const { data, loading, error } = useQuery(query, {
|
|
variables: {id}
|
|
})
|
|
|
|
if (loading) return (
|
|
<div className="uk-container">
|
|
<p>loading...</p>
|
|
</div>
|
|
)
|
|
if (error) return <p>Error: {JSON.stringify(error)}</p>
|
|
return children({ data })
|
|
}
|
|
|
|
export default Query |