You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{useApolloClient,useQuery}from"@apollo/react-hooks";import{gql}from"apollo-boost";constfetchGoalsQuery=gql` query FetchGoals($name: String!) { gitHub { viewer { repository(name: $name) { id issues(first: 10, states: OPEN, orderBy: {direction: DESC, field: CREATED_AT}) { totalCount nodes { id title body number labels(first: 3) { nodes { color name id } } } } } } } }`;// useQuery succeeds but the data and error returns undefined. const{data, error}=useQuery(fetchGoalsQuery,{name: "open-sauced-goals"});// data and error are undefinedconsole.log("error",error);console.log("data",data);
The text was updated successfully, but these errors were encountered:
bdougie
changed the title
Caching with the OneGraphApolloClient
Caching with the OneGraphApolloClient and hooks
Nov 23, 2019
bdougie
changed the title
Caching with the OneGraphApolloClient and hooks
Fetching with OneGraphApolloClient and hooks
Nov 23, 2019
I was able to get this to work without hooks. I ended up using zeit/swr. It has less assumptions about my GraphQL Client setup. Since I am using the onegraph-auth package requires a slightly different setup for the client, which was clashing with the apollo/react-hooks.
useSWR allowed me to leverage my existing onegraph fetcher to return data and populate my cache.
Once I clean this up I might wrap this in a custom hook.
Questions
Do you have examples of someone using OneGraph with @apollo/react-hooks?
My Attempt:
I am attempting to add caching in this draft PR: bdougie/open-sauced#379.
@apollo/react-hooks
apollo-cache-inmemory
The text was updated successfully, but these errors were encountered: