graphq apollo useueryt code example
Example 1: appolo client variables pass
const query = gql`
query User($okta: String) {
User(okta: $okta){
id
}
}
`;
client.query({
query: query,
variables: {
okta: 'some string'
}
})
Example 2: apoolo uselaxyQuery bypass cache
const { data: cachedData } = useQuery(MyQuery, { fetchPolicy: 'cache-only', variables });
const [executeMyQuery, { data: queryData, loading, error }] = useLazyQuery(MyQuery, {
fetchPolicy: 'network-only'
});
const data = queryData || cachedData;