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

3353 questions
74
votes
3 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,419
  • 1
  • 12
  • 20
59
votes
6 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
  • 823
  • 1
  • 7
  • 19
55
votes
9 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
  • 23,342
  • 38
  • 121
  • 218
54
votes
6 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
  • 8,159
  • 8
  • 33
  • 55
49
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…
GRS
  • 1,829
  • 1
  • 9
  • 23
48
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
  • 46,433
  • 78
  • 254
  • 460
40
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,897
  • 2
  • 15
  • 16
37
votes
1 answer

How to remove the `__typename` field from the graphql response which fails the mutations

I tried changing the addTypeName: false in the Apollo client in GraphQL apollo.create({ link: httpLinkWithErrorHandling, cache: new InMemoryCache({ addTypename: false }), defaultOptions: { watchQuery: { fetchPolicy: 'network-only', …
Rigin Oommen
  • 3,060
  • 2
  • 20
  • 29
34
votes
3 answers

GraphQL mutation: Invariant Violation: Must contain a query definition

I am trying to make a mutation call to my graphQL server from a react application. The react code looks like the following: client.query({ query: gql` mutation{ addTeam(input:{name:"Somename", label:"somelabel"}) {error,…
Siddhartha Chowdhury
  • 2,724
  • 1
  • 28
  • 46
32
votes
5 answers

How to refresh JWT token using Apollo and GraphQL

So we're creating a React-Native app using Apollo and GraphQL. I'm using JWT based authentication(when user logs in both an activeToken and refreshToken is created), and want to implement a flow where the token gets refreshed automatically when the…
user3043462
  • 456
  • 1
  • 5
  • 7
32
votes
5 answers

apollo-client does not work with CORS

I am writing a graphql server component on AWS Lambda (NOT using graphql-server). On the client side I'm using apollo-client. On the response of the lambda function I'm setting const response = { statusCode: 200, headers: { …
tmp dev
  • 8,043
  • 16
  • 53
  • 108
32
votes
3 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,873
  • 2
  • 15
  • 34
31
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
  • 11,670
  • 5
  • 22
  • 23
30
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…
Oleksandr Fomin
  • 2,005
  • 5
  • 25
  • 47
30
votes
4 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,581
  • 2
  • 32
  • 52
1
2 3
99 100