apollo-client

Proper way of refetching queries after mutation in React + ApolloClient project

我与影子孤独终老i 提交于 2021-01-28 06:10:14
问题 Creating an app which allows you to sign up and sign in user in the database. After sign up / sign in process the app moves you to the content. Code for authorization process: const Auth = ({ handleSetAuthorized }) => { const { refetch } = useQuery(CURRENT_USER) const { error } = useSelector(({ error }) => error) const history = useHistory() const dispatch = useDispatch() const [signup] = useMutation(SIGN_UP, { onCompleted: async (data) => { const token = data.signup localStorage.setItem(

dynamic query graphql apollo with java

走远了吗. 提交于 2021-01-28 02:40:14
问题 The routine of working with the graphql apollo is that add file query .graphql i would create dynamic query with java and i do not create file for each query example querys : one : query EntryDetailQuery($repoFullName: String!) { entry(repoFullName: $repoFullName) { id repository { full_name description owner { login } } postedBy { login } } } two : just request full_name query EntryDetailQuery($repoFullName: String!) { entry(repoFullName: $repoFullName) { id repository { full_name } } } in

Apollo GraphQL requests are canceled

∥☆過路亽.° 提交于 2021-01-27 20:45:26
问题 I am building a React type ahead text field component using Downshift and react-apollo . As the user types I am querying type ahead suggestions and present them underneath the text field. Unfortunately, this experience is not going smoothly. For some reason every now and then Apollo cancels more than 50 percent of the requests. I am also logging the response data that is accessible to the component wrapped with the graphql HoC. In the desired case, the loading state is set to false and my

When to use Apollo's cacheRedirects?

倾然丶 夕夏残阳落幕 提交于 2021-01-27 05:40:49
问题 The Apollo documentation discusses the use of cacheRedirects to tell Apollo how to access data that's already in the cache from other query. It gives an example of this: In some cases, a query requests data that already exists in the client store under a different key. A very common example of this is when your UI has a list view and a detail view that both use the same data. The list view might run the following query: query ListView { books { id title abstract } } When a specific book is

When to use Apollo's cacheRedirects?

泪湿孤枕 提交于 2021-01-27 05:39:40
问题 The Apollo documentation discusses the use of cacheRedirects to tell Apollo how to access data that's already in the cache from other query. It gives an example of this: In some cases, a query requests data that already exists in the client store under a different key. A very common example of this is when your UI has a list view and a detail view that both use the same data. The list view might run the following query: query ListView { books { id title abstract } } When a specific book is

Apollo graphql setting header to authmiddleware not working

╄→尐↘猪︶ㄣ 提交于 2021-01-07 03:33:05
问题 I am using react-native and apollo client and if I try to set header by jwt stored in AsyncStorage, it seems not working. Other resolvers which doesn't need header works very well. My code is like below. import { ApolloClient } from "apollo-client"; import { InMemoryCache } from "apollo-cache-inmemory"; import { ApolloLink } from "apollo-link"; import { createHttpLink } from "apollo-link-http"; import AsyncStorage from "@react-native-community/async-storage"; const cache = new InMemoryCache()

Apollo graphql setting header to authmiddleware not working

孤街醉人 提交于 2021-01-07 03:28:04
问题 I am using react-native and apollo client and if I try to set header by jwt stored in AsyncStorage, it seems not working. Other resolvers which doesn't need header works very well. My code is like below. import { ApolloClient } from "apollo-client"; import { InMemoryCache } from "apollo-cache-inmemory"; import { ApolloLink } from "apollo-link"; import { createHttpLink } from "apollo-link-http"; import AsyncStorage from "@react-native-community/async-storage"; const cache = new InMemoryCache()

Apollo graphql setting header to authmiddleware not working

纵然是瞬间 提交于 2021-01-07 03:27:07
问题 I am using react-native and apollo client and if I try to set header by jwt stored in AsyncStorage, it seems not working. Other resolvers which doesn't need header works very well. My code is like below. import { ApolloClient } from "apollo-client"; import { InMemoryCache } from "apollo-cache-inmemory"; import { ApolloLink } from "apollo-link"; import { createHttpLink } from "apollo-link-http"; import AsyncStorage from "@react-native-community/async-storage"; const cache = new InMemoryCache()

Apollo graphql setting header to authmiddleware not working

两盒软妹~` 提交于 2021-01-07 03:27:00
问题 I am using react-native and apollo client and if I try to set header by jwt stored in AsyncStorage, it seems not working. Other resolvers which doesn't need header works very well. My code is like below. import { ApolloClient } from "apollo-client"; import { InMemoryCache } from "apollo-cache-inmemory"; import { ApolloLink } from "apollo-link"; import { createHttpLink } from "apollo-link-http"; import AsyncStorage from "@react-native-community/async-storage"; const cache = new InMemoryCache()

refresh token for angular using graphql and apollo client

≯℡__Kan透↙ 提交于 2021-01-05 07:34:27
问题 I'm trying to set up a refresh token strategy to refresh JWT in angular 9 with GraphQL and apollo client when my first request returns a 401. I have set up a new angular module for graphql where I'm creating my apolloclient. Everything works great even with authenticated requests but I need to have my normal refresh token strategy work as well (re-make and return the original request after refresh token cycle completes). I have found only a few resources to help with this and I've gotten