Questions tagged [react-apollo-hooks]

89 questions
1
vote
1 answer

Cannot read proper query in GraphQL Apollo Client

On one of my pages in my app I'm doing two api calls with graphql apollo client. One is document, the other one menu. I need menu data in one of my components so I want to use readQuery in order to not to fetch it again. What I'm doing is: const…
Murakami
  • 3,474
  • 7
  • 35
  • 89
0
votes
1 answer

What is the better way to handle conditional useQuery calls in apollo client react?

We have this query with according types: const GET_ITEM = gql` query GetItem($itemId: Int!) { item(where: { itemId: $itemId }) { name } } `; type TQuery = { item: string }; type TVariables = { itemId: number }; What is the better…
0
votes
0 answers

Apollo useQuery hook's returns data that is not the same with its cache's read policy

Heyaa... I'm kind of a newbie in configuring Apollo cache for handling paginations, thus I'm facing this issue... Currently, I'm successfully added some field policies to my InMemoryCache options, able to smoothly paginate data. But, it all turns…
0
votes
1 answer

How to best store data locally - useMutation vs writeQuery

I'm using Apollo Client 3 for my NextJS project. What I need to do is save nested data locally. I first implemented a function with reactive variables but from my experience, it's not the best approach when dealing with nested data. What I found out…
0
votes
1 answer

how can I supply a a variable to a query that can be used to specify a field to sort a returned array by?

I have built this query to request data from the Pokeapi graphQL server here https://beta.pokeapi.co/graphql/console/ query getOrderedPokemon ( $sortOrder: order_by, ) { pokemon_v2_pokemon( limit: 20, order_by: { name :…
Jon_B
  • 969
  • 4
  • 16
  • 24
0
votes
1 answer

How to write useMutation hook with onCompleted as a parameter?

I need to write dedicated hook useMutation with onCompleted and parameter onMutationCompleted. In file it uses like: const [data] = useClearWorkerMutation({ onCompleted: onMutationCompleted }); I don't know how to put onCompleted in this hook…
0
votes
1 answer

cache.writeData is not a function -> inMemoryCache error

I'm working with react and apollo client. i'm get confusing error and i can't find exactly the problem. i have the code. import logo from './logo.svg'; import './App.css'; import Pages from './pages'; import GlobalStyles from…
0
votes
0 answers

apollo-client transforms response

I am working on a React application and I am facing an issue with Apollo client (@apollo/client 3.3.6). I am not sure if I am missing some configurations or what. For a query, Apollo client somehow transforms my response i.e., the response that…
Kashif Nazar
  • 20,775
  • 5
  • 29
  • 46
0
votes
1 answer

Apollo Client - Separating paginated queries for same field name but with different filters

I was able to use relayStylePagination fairly easily for creating a paginated feed of Post objects for users on my app. However, I’d like to use that same field and pagination process but with a filter for a specific user when visiting their page.…
0
votes
1 answer

Apollo GraphQL failing connection

My root component is already wrapped with an ApolloProvider tag, but the error message tells me it is not. Error Message Invariant Violation: Could not find "client" in the context or passed in as an option. Wrap the root component in an…
0
votes
1 answer

Missing field __typename while using graphql query with apollo react-hooks

I'm facing a issue with query in GRAPHQL Here is my query const discussionform = gql` query totara_mobile_discussion { discussion { __typename us sys } } `; I'm using react-hooks. import { useQuery } from…
0
votes
1 answer

How do I buffer streamed data with react-hooks (useEffect) to be able to update another component at once to avoid many rerenderings?

How do I buffer streamed data with react-hooks (useEffect) to be able to update another component at once to avoid many rerenderings? Following information is just additional background for complete understanding. In the end the overall question is…
0
votes
1 answer

How to delete cache record from Apollo GraphQL client with readQuery and writeQuery

The Apollo GraphQL team says that readQuery and writeQuery are good for 95% of the use cases. I am using useMutation and update and want to remove an item from a cache without having to call refetchQueries. My code is as follows: const…
Pete
  • 3,111
  • 6
  • 20
  • 43
0
votes
2 answers

Batching with useQuery react hooks getting back undefined

I am currently working on a project which requires me to make multiple queries/mutations. I tried setting up my apollo client with BatchHttpLink and I can see the data I am requesting in the network tab in the browser. It is coming back at an array…
0
votes
1 answer

Recieved this error: Error: Too many re-renders. React limits the number of renders to prevent an infinite loop

I've a stepper form, that insert data using GraphQL/Apollo and React, of two different places. Here are the code: export function ProjectStep({classes, nextStep}) { const {loading, error, data} = useUserQuery(); const…
Baptista
  • 128
  • 2
  • 11