Questions tagged [react-apollo-hooks]
89 questions
2
votes
1 answer
How to update variables in a React-Hooks Apollo polling?
I'm using @apollo/react-hooks to poll data from a GraphQL query each 5mn.
My query accepts a list of parameters including the current date time like this:
const MyComponent = ({ query }) => {
const {loading, error, data} = useQuery(query, {
…

Ala Eddine JEBALI
- 7,033
- 6
- 46
- 65
2
votes
2 answers
Component not rendering when using children as function
I am using react-apollo to query the graphQL server and able to successfully hydrate the client with the data. As there will be more than a single place I will be querying for the data I am trying to create a container (refactor) to encapsulate the…

Sushanth --
- 55,259
- 9
- 66
- 105
2
votes
1 answer
Why am I able to conditionally call a hook one way, but not the other?
Context:
When I refresh the dashboard, useHasPermission makes an async call to determine if the
user has access to somePermission.
Issue:
hasPermission initially evaluates to false, but once the async call has completed hasPermission evaluates to…

jinan
- 173
- 1
- 10
2
votes
1 answer
Cant Set Apollo Local State with nested values
I'm testing out Apollo Graphql with React and I'm trying to update the local state with Apollo Graphql with a nested object. I'm running into an issue. The data returns a null value and does not even return the value I set as a default. The only…

Chris Bryant
- 123
- 7
2
votes
2 answers
React Apollo Hooks - Chain mutations
I have two mutations:
const [createRecord, {data}] = useMutation(createRecordQuery); which returns the ID of the newly created record
const [saveValue, {data: dataSave}] = useMutation(saveValueQuery); which save some values on a record
My…

Tdy
- 863
- 12
- 28
2
votes
1 answer
GraphQL Apollo React Hooks queries return null depending on order of initialization
I am using two @apollo/react-hooks's useQuery hooks for querying my db but I noticed when printing them out to console ones data was undefined. I tried numerous things and couldn't fix it. I then tried switching the order of the hooks and noticed…

athammer
- 159
- 1
- 14
2
votes
2 answers
UseApolloClient query won't return fetchMore
I am working on project with Apollo on client side. I am using react-apollo-hooks on my client side. And I have a problem with useApolloClient.
When i fire query with my client I got in useApolloClient I don't get back all data I need. FetchMore is…

Lule
- 95
- 2
- 7
1
vote
0 answers
Apollo cache-and-network policy always bypasses the cache
Using Apollo Client 3.6.9 and generated React query hooks (from codegen) I see this strange behaviour where a component uses cache as expected whenever no fetchPolicy is provide (and it's using the default "cache-first" policy), but if I change it…

Knut Marius
- 1,588
- 18
- 40
1
vote
1 answer
Does useQuery refetch invalidates cache?
I would like to know if the refetch function that the useQuery hook returns invalidates the cache, since I need to retrieve the newest data from the resolver after a mutation is triggered. Is refetch enough or should I invalidate the cache…

agustin37
- 121
- 6
1
vote
1 answer
Unit testing Apollo useMutation onCompleted
I have an onCompleted that I am trying to test from my useMutation, I am using jest and react-testing-library. This is the piece of code I am trying to test
this is my react code:
const [deleteJobs] = useMutation

Lauraful
- 21
- 1
- 2
1
vote
0 answers
React Apollo (GraphQL): How to stop Query component from re-fetching on each state change
I have a React component inside which I have a react-apollo Query component which fetches data using graphql based on some filters (hooks) that are managed inside the same component which houses the query component. The required functionality would…

Hardik Aswal
- 227
- 3
- 15
1
vote
1 answer
Apollo Client useQuery react hook for GET requests
The API resource I am trying to pull from expects a GET request.
How can I use the useQuery hook to send a GET request, it seems like it only ever sends POST requests.
In my limited understanding of GraphQL, should the server be changed so the…

YellowGuy
- 458
- 1
- 5
- 12
1
vote
0 answers
How to refetch apollo watchQuery after cache invalidation with cache-first / cache-and-network
I have some meta data which rarely updates, but it can update once in a while. Within my application the user access this information very frequently, which puts quite some load on my servers.
I'd like to refetch it only eg once a day to check if…

Manuel
- 9,112
- 13
- 70
- 110
1
vote
0 answers
UseEffect doesn't trigger on second change, but trigger twice on launch.(React hooks and apollo-graphql hooks)
useEffect doesn't trigger on second change, but triggers twice on launch (React hooks and apollo-graphql hooks).
In console.logs I described when the changes are triggered and when not.
I don't have any more clue to add.
Here's my page (Next.js…

Wiktor Kujawa
- 595
- 4
- 21
1
vote
0 answers
Mutation is not a function?
I want to use social login by using graphql.
I want to get accessToken from social login by using kakaologin function and then i use it to make token by using kakakoLoginMutation function.
I try to make const name is access_token(=="123")
and if i…

박형렬
- 377
- 1
- 9
- 24