Questions tagged [apollo-client]

Apollo Client is a JavaScript library for building client UIs that fetch data using GraphQL.

Apollo Client is the best way to use GraphQL to build client applications. The client is designed to help you quickly build a UI that fetches data with GraphQL, and can be used with any JavaScript front-end.

Apollo Client

Repository

2324 questions
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
32
votes
3 answers

Apollo Client Cache vs. Redux

I'm trying to migrate from Redux Store to use Apollo Client Cache that comes with Apollo Graphql Client. One of the key features that sets Apollo Client apart from other data management solutions is its normalized cache. Just by setting up Apollo…
32
votes
6 answers

Using ApolloClient with node.js. "fetch is not found globally and no fetcher passed"

I am attempting to use an Apollo Client on a node.js server to interface with another GraphQL API using the following code: import fetch from 'node-fetch' import { createHttpLink } from 'apollo-link-http' import ApolloClient from…
Nathan
  • 1,187
  • 2
  • 10
  • 16
29
votes
3 answers

GraphQL dynamic query building

I have a GraphQL server which is able to serve timeseries data for a specified source (for example, sensor data). An example query to fetch the data for a sensor might be: query fetchData { timeseriesData(sourceId: "source1") { data { …
Matt Wilson
  • 7,359
  • 7
  • 28
  • 51
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

Add custom header to apollo client polling request

I am using the apollo-client library to query data from my Graphql server. Some of the queries are sent to the server every 5 seconds through apollo polling ability. Is there a generic way to add a custom header to all requests that are sent by my…
Ron Badur
  • 1,543
  • 2
  • 10
  • 25
22
votes
3 answers

Why I got error: Cannot query field xx on type "Query"?

Although I copied and pasted the graphQL query from the GraphiQL tool after I tested it at GraphiQL successfully , the query returned with an error when I tried it in Apollo client within a reactJS app: [GraphQL error]: Message: Cannot query field…
simo
  • 20,548
  • 31
  • 101
  • 188
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
21
votes
3 answers

Deleting Apollo Client cache for a given query and every set of variables

I have a filtered list of items based on a getAllItems query, which takes a filter and an order by option as arguments. After creating a new item, I want to delete the cache for this query, no matter what variables were passed. I don't know how to…
20
votes
5 answers

How to force Apollo Query component to re-run query when parent component re-renders

I'm using Apollo Client's within a component that is re-rendered when state is changed within a lifecycle method. I wish to have my component re-run the query because I know that data has changed. It appears that Query component is…
Andrei R
  • 3,282
  • 5
  • 23
  • 26
19
votes
2 answers

Apollo 3 pagination with Field Policies

Could someone provide an example of pagination implemented with Apollo Client 3.0 Field Policies. I've been following the example from the docs to implement infinite scroll but in my console I'm getting the following warning: The updateQuery…
Aleksandr Fomin
  • 699
  • 5
  • 18
18
votes
1 answer

When to use watchQuery or query in Apollo-Angular?

I am using a watchQuery or query in Apollo-Angular (graphql) How is the logic and difference of the watchQuery and query
yussenn
  • 447
  • 1
  • 4
  • 11
1
2 3
99 100