react-apollo-hooks

Custom ApolloProvider for access to React Context inside

烈酒焚心 提交于 2020-06-01 05:08:40
问题 I created ApolloCustomProvider because I want to use addNotification function from my AppContext for graphQL error handling. The problem is that this custom provider seems to work while querying or mutating API but errorLink 's functions like addNotification and console.log() doesn't work. Also console.log() from request function doesn't print anything. But when I put everything from ApolloCustomProvider to standard TypeScript file (.ts - not React Component) and then use it like: import {

React Apollo Client - modify query data before it goes to cache

白昼怎懂夜的黑 提交于 2020-01-14 05:08:06
问题 Is there a way to modify query response data before it is saved in the internal cache? I'm using apollo hooks, but this question is relevant to any of front-end approaches using apollo client (HOC & Components as well). const { data, updateQuery } = useQuery(QUERY, { onBeforeDataGoesToCache: originalResponseData => { // modify data before it is cached? Can I have something like this? return modifiedData; } }); Obviously onBeforeDataGoesToCache does not exist, but that's exactly the behavior I

Does onCompleted works with useMutation?

你离开我真会死。 提交于 2019-12-10 11:26:45
问题 I am using useMutation hook in react project. The mutation runs successfully but it's not reaching onCompleted afterwards. I have set notifyOnNetworkStatusChange to true in the mutation but that doesn't seem to help. const [createUser] = useMutation(SIGNUP_MUTATION); createUser({ variables: { firstname, lastname, email }, notifyOnNetworkStatusChange: true, onCompleted: (data) => { // not called confirm(data); } }); 回答1: Looking at the api of useMutation it seems like you're using onCompleted

Does onCompleted works with useMutation?

自古美人都是妖i 提交于 2019-12-06 07:38:36
I am using useMutation hook in react project. The mutation runs successfully but it's not reaching onCompleted afterwards. I have set notifyOnNetworkStatusChange to true in the mutation but that doesn't seem to help. const [createUser] = useMutation(SIGNUP_MUTATION); createUser({ variables: { firstname, lastname, email }, notifyOnNetworkStatusChange: true, onCompleted: (data) => { // not called confirm(data); } }); Looking at the api of useMutation it seems like you're using onCompleted in the wrong place. it should be part of the useMutation definition. const [createUser] = useMutation(