Questions tagged [react-apollo]

React Apollo allows you to fetch data from your GraphQL server and use it in building complex and reactive UIs using the React framework. React Apollo may be used in any context that React may be used. In the browser, in React Native, or in Node.js when you want to do server-side rendering.

react-apollo tag should be used for questions that are about the usage of the react-apollo ApolloClient container.

It should be included with the apollostack (and related) tags to clarify that this is the client wrapper being used.

It alleviates the need to use the , which should not be used, unless a person who knows nothing about react-apollo is likely to be able to answer the question.

Related tags

2335 questions
9
votes
4 answers

"Cannot read property _location of null" when using React Apollo in a Jest test case

Given the following component: export function App() { return withApollo( ); } // MatchListRouteHandler export const Query = addTypenameToDocument(gql` query GetMatches { …
Dan
  • 10,282
  • 2
  • 37
  • 64
9
votes
2 answers

How to call an apollo client query from a redux action

If I'm using redux and the apollo client in my app, what's the best way to trigger a query from an action outside of a component. For example, if I have a standard app, with redux and apollo client configured, how should I trigger a "refresh" list. …
MonkeyBonkey
  • 46,433
  • 78
  • 254
  • 460
8
votes
1 answer

Add nested fields in cache typePolicies - Apollo v3

I am wondering if it is possible to have nested values using typePolicies of the InMemoryCache For now you can define flat fields policies new InMemoryCache({ typePolicies: { Query: { fields: { hello: { read() { …
Simon Bruneaud
  • 2,263
  • 2
  • 12
  • 24
8
votes
3 answers

How to use localStorage with apollo-client and reactjs?

I need to make a cart for an online shop using reactjs and apollo-client. How can I persist data using apollo-client with localStorage?
user246328
  • 103
  • 1
  • 1
  • 6
8
votes
1 answer

How to properly pass variables to apollo useQuery?

So I need a pair of fresh eyes to help me out! I just started using the new hooks for apollo and they are pretty cool! However, I am running into an issue when I try to pass variables, it returns undefined. I have this query in a graphql server…
aromanarguello
  • 626
  • 4
  • 11
  • 23
8
votes
2 answers

AWS AppSync + React-Apollo Query/useQuery raising exception this.currentObservable.query.getCurrentResult is not a function

I'm new to GraphQL/Apollo thing and I'm having a hard time to setup it with a React application. I have a React component that loads a list from a GraphQL API built using Amplify/AppSync. If I call manually to fetch the items, i.e: const…
dfranca
  • 5,156
  • 2
  • 32
  • 60
8
votes
0 answers

How to display a pretty error with apollo link error

I've a problem with apollo-link-error, I'm able to log the error but I would like show a modal with the error or display it on another page, is it possible without handling the error on each request ? React, Apollo-client/server,…
Ezaos
  • 136
  • 4
8
votes
2 answers

Testing Apollo Mutation graphql errors

According to the docs, I should be able to to mock graphql errors in order to test. To simulate GraphQL errors, simply define errors along with any data in your result. const dogMock = { // ... result: { errors: [{ message: "Error!" }], …
user3009902
  • 97
  • 1
  • 5
8
votes
1 answer

How to combine two dependent GraphQL queries with 'compose'?

Solved! I'm trying to combine two dependent GraphQL queries. The first one should get an ID and the second one should take that ID. I read that compose behaves like flowRight(), but no matter in what order I put the queries, if queryId is below…
psgmnd
  • 83
  • 1
  • 7
8
votes
2 answers

React-Select with React-Apollo does not work

We are using react-select and fetching the items as the user types. I am not able to make it work with react-apollo. Can someone help me provide a guideline? Here is my unsuccessful attempt: class PatientSearchByPhone extends Component { …
Nishant
  • 54,584
  • 13
  • 112
  • 127
8
votes
0 answers

React-apollo: Change variables without refetching in a polling query

Is there a way so we can change the variables in a query without refetching? My use case is when you have a polling query and you want to skip or include a part of the query according to a user's action. for example const USER_STATS = gql` query…
8
votes
4 answers

React Apollo Client not sending cookies

I have tried following the instructions on Apollo Client for sending cookies along with the graphql request, but the express server is not receiving any cookies and when I inspect the request it shows that no cookies are being sent with the…
wbruntra
  • 1,021
  • 1
  • 10
  • 18
8
votes
2 answers

Apollo Client Write Query Not Updating UI

We are building an offline first React Native Application with Apollo Client. Currently I am trying to update the Apollo Cache directly when offline to update the UI optimistically. Since we offline we do not attempt to fire the mutation until…
Dadles
  • 119
  • 1
  • 1
  • 10
8
votes
1 answer

React Apollo: One query, multiple arguments - How to cache?

I am puzzled by this. Suppose I currently have a the following query: export const getPokemon = gql` query getPokemon($filters: AssetFilters) { pokemon(filters: $filters) { name, generation, exp } }`; By default no…
dipole_moment
  • 5,266
  • 4
  • 39
  • 55
8
votes
3 answers

How to force update data cache in react-apollo?

How to refetch fresh data when you revisit a page whose data is powered by react-apollo? Say, I visit a listing page for the first time. apollo will fetch the query and caches it by default. So, when you visit the same page again during the session,…
Pranesh Ravi
  • 18,642
  • 9
  • 46
  • 70