Skip to content

Instantly share code, notes, and snippets.

@morrys
Created August 5, 2020 15:02
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