Created
August 5, 2020 15:02
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 {useQuery, graphql } from 'relay-hooks'; | |
const query = graphql` | |
query appQuery($userId: String) { | |
user(id: $userId) { | |
...TodoApp_user | |
} | |
} | |
`; | |
const variables = { | |
userId: 'me', | |
}; | |
const options = { | |
fetchPolicy: 'store-or-network', //default | |
networkCacheConfig: undefined, | |
} | |
const AppTodo = function (appProps) { | |
const {props, error, retry, cached} = useQuery(query, variables, options); | |
if (props && props.user) { | |
return <TodoApp user={props.user} />; | |
} else if (error) { | |
return <div>{error.message}</div>; | |
} | |
return <div>loading</div>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment