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

2126 questions
61
votes
3 answers

How to disable cache in apollo-link or apollo-client?

I'm using apollo-client, apollo-link and react-apollo, I want to fully disable cache, but don't know how to do it. I read the source of apollo-cache-inmemory, it has a config argument in its constructor, but I can't build a dummy storeFactory to…
Jacky Lee
  • 892
  • 1
  • 7
  • 11
49
votes
2 answers

Handling errors with react-apollo useMutation hook

I have been trying to get my head around this problem but haven't found a strong answer to it. I am trying to execute a login mutation using the useMutation hook. TLDR; I want to know what exactly is the difference between the onError passed in…
d_bhatnagar
  • 1,049
  • 1
  • 10
  • 17
47
votes
4 answers

Error: Network error: Error writing result to store for query (Apollo Client)

I am using Apollo Client to make an application to query my server using Graphql. I have a python server on which I execute my graphql queries which fetches data from the database and then returns it back to the client. I have created a custom…
return007
  • 703
  • 1
  • 6
  • 16
44
votes
1 answer

Apollo client is giving me an error of 'store already contains an id' - what does that mean?

In a react native project I am creating an object and then redirecting the screen to the newly created object's details page and I'm getting this error: Possible Unhandled Promise Rejection (id: 0): Network error: Store error: the application…
MonkeyBonkey
  • 40,521
  • 63
  • 217
  • 426
40
votes
10 answers

React Apollo - Make Multiple Queries

I have a queries file that looks like this: import {gql} from 'react-apollo'; const queries = { getApps: gql` { apps { id name } } `, getSubjects: gql` { subjects { id name …
user2465134
  • 6,278
  • 5
  • 23
  • 39
35
votes
1 answer

GraphQLError: Syntax Error: Expected Name, found

I got the above error on a graphql query, I am using apollo-react by the way and using the Query component for rendering the data this is my code const GET_VEHICLE_CHECKS = gql` query getVehicleChecks($uuid: String!) { tripDetails(uuid: $uuid){ …
malik bagwala
  • 1,338
  • 2
  • 11
  • 26
32
votes
8 answers

GraphQL gql Syntax Error: Expected Name, found }

I'm attempting to set up Apollo GraphQL support in a new React project, but when I try to compile a query using gql I keep receiving the error: Syntax Error: Expected Name, found } This is generated by the following code: import gql from…
Nathan
  • 1,187
  • 2
  • 10
  • 16
30
votes
6 answers

How do I handle deletes in react-apollo

I have a mutation like mutation deleteRecord($id: ID) { deleteRecord(id: $id) { id } } and in another location I have a list of elements. Is there something better I could return from the server, and how should I update the…
derekdreery
  • 3,280
  • 4
  • 27
  • 38
27
votes
1 answer

use query hook react Apollo conditional call

I have been using react-apollo and the render prop approach. This worked perfectly and my code looked something like this. const App = () => { const [player, setPlayer] = React.useState(null); if (player) { return ( …
peter flanagan
  • 6,130
  • 13
  • 50
  • 94
24
votes
2 answers

How to chain two GraphQL queries in sequence using Apollo Client

I am using Apollo Client for the frontend and Graphcool for the backend. There are two queries firstQuery and secondQuery that I want them to be called in sequence when the page opens. Here is the sample code (the definition of TestPage component is…
afterglowlee
  • 9,680
  • 5
  • 17
  • 23
24
votes
6 answers

How to update the Redux store after Apollo GraphQL query returns

I'm fetching a list of data with the graphql HOC provided by react apollo. E.g.: const fetchList = graphql( dataListQuery, { options: ({ listId }) => ({ variables: { listId, }, }), props: ({ data: { loading,…
TheWebweiser
  • 571
  • 4
  • 10
23
votes
2 answers

Setting state in the Query component of react-apollo

So, I'm trying to set an initial state for an edit component that gets data from the server and now should be editable in the component state. But when I try to do this:
Andreas
  • 1,064
  • 3
  • 11
  • 24
22
votes
4 answers

Type error: JSX element type '{} | null | undefined' is not a constructor function for JSX elements

I have a React component called HandleQuery that handles the results of an Apollo GraphQL query: import React, { ReactNode } from 'react'; import { CenteredMessage } from './centered-message'; export interface HandleQueryProps { loading:…
Naresh
  • 18,757
  • 25
  • 99
  • 162
22
votes
4 answers

Apollo GraphQl react. How to clear query cache for all variable combinations?

I am using apollo graphql in my react application. Say I have the following query: query ListQuery($filter: String!) { items(filter: $filter) { id name } } This query lets me query a list of items using a filter. Say I used filter…
Andy Hansen
  • 281
  • 1
  • 3
  • 6
21
votes
2 answers

How to execute an async fetch request and then retry last failed request?

Apollo link offers an error handler onError Issue: Currently, we wish to refresh oauth tokens when they expires during an apollo call and we are unable to execute an async fetch request inside the onError properly. Code: initApolloClient.js import…
Mysteryos
  • 5,183
  • 2
  • 25
  • 49
1
2 3
99 100