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
1
vote
1 answer

How to force Apollo Client to use cached data for detail view page

I have a paginated cursor based query TODOS and detail page with query TODO to get data by ID. Whenever I go to detail view and use useQuery with TODO query (Which contains exactly same data as TODOS query result, it still tries to get data from…
Vano
  • 690
  • 3
  • 8
  • 25
1
vote
1 answer

How to catch errors with ApolloProvider globally

I'm trying to catch all my graphQLErrors with the onError method from apollo client. My goal is to have only one catch block for all of my API calls. const errorLink = onError(({ graphQLErrors, networkError ,operation}) => { if (graphQLErrors &&…
Ar26
  • 949
  • 1
  • 12
  • 29
1
vote
0 answers

Switch conditionally between client and server resolvers with @client directive

I need to be able to use server resolvers in development env, but in all other evs, I want to use the client resolvers. I was checking if there is an elegant way to skip the @client directive in development. For now, it seems that the simplest is to…
1
vote
0 answers

ReactJS(using apollo-client) not setting cookies received from ExpressJS(using apollo-server-express)

I've created simple backend api using apollo-server-express and postgresql that has two mutations: register and login. When the login mutation is used, the api creates an auth token and a refresh token and then sends them as cookies using…
1
vote
3 answers

NuxtJS Apollo module TypeError: Cannot read property '$apolloHelpers' of undefined

I am building a simple NuxtJS app that consume a GraphQL endpoint using NuxtJS Apollo module. I am currently building the authentication part of the app. I wanted to use apolloHelpers.onLogin() function to set the auth header in cookie and invoke…
sdil
  • 41
  • 1
  • 5
1
vote
1 answer

How to get and set a ref for a newly cached related object in Apollo client InMemoryCache?

I have a set of related items like so: book { id ... related_entity { id ... } } which apollo caches as two separate cache objects, where the related_entity field on book is a ref to an EntityNode object. This is fine, the related…
1
vote
1 answer

Loading __typename fields in seperate queries Apollo-Client not Updating UI

I'm attempting to load information about a type in 2 steps (since the info I'm asking for in secondQuery will take some time to load): Component: const MyComponent = ({startDate}) => { const firstQuery = useQuery( GET_INFO_PART_ONE, { …
jolavb
  • 11
  • 1
1
vote
1 answer

Property 'subscriptionClient' is private and only accessible within class 'WebSocketLink'.ts(2341)

"@apollo/client": "^3.0.2" "@types/node": "^14.0.20", "@types/react": "^16.9.49", "typescript": "^4.0.3" So I'm getting the above mentioned error when attempting to convert a file to typescript on the following code: lib/withData.ts import {…
TheoG
  • 1,498
  • 4
  • 30
  • 54
1
vote
0 answers

Sample Apollo Client code to test APQ (Automated Persistent Queries)

I was trying to test APQ with a server written in haskell. The following is the sample Apollo client code, I wrote to test it: const { createPersistedQueryLink } = require("apollo-link-persisted-queries") const { createHttpLink } =…
Naveen
  • 85
  • 8
1
vote
3 answers

Prisma and ApolloClient: Prevent overwriting the include conditions at the backend by the frontend for relations

I have a problem, thx for any help. With prisma we can use include with where conditions for models with a relation. If I make include conditions I get the right result. If I return it to the frontend it gets overwritten. I want to return exact my…
Tölz
  • 766
  • 2
  • 8
  • 18
1
vote
0 answers

How to do complex queries on apollo cache

I have a todo list application that I'm experimenting with that has subtasks. Each parent task has a children array containing the ids of the child tasks. Once the parent task is expanded, the query to the server kicks off to populate those child…
Scott
  • 3,204
  • 3
  • 31
  • 41
1
vote
1 answer

Prisma: Most performant way to query for sub relations

I want to query for posts and for each post I wan't just the like from the current user. I have 2 solutions and both are working. But which one is better? Or are there better solutions? Frontend: React + ApolloClient Backend: Primsa2 + Graphql…
Tölz
  • 766
  • 2
  • 8
  • 18
1
vote
0 answers

Apollo typepolicies how to read sibling field of Query?

in my type policy typepolicies:{ Query:{ fields:{ getCartItems:{ //This is a local field //I want to reference "allProducts" field here }, …
notinsky
  • 51
  • 1
  • 3
1
vote
0 answers

Apollo Client 3: Cache data may be lost when replacing the nuggets field of a Query object

I'm using Postgraphile to generate a Graphql schema for me. I am using Apollo Client 3 to help with querying/caching. Here is the relevant shape of my schema: Query -> buckets: BucketsConnection -> edges: BucketsEdge -> node: Bucket Query ->…
Tycholiz
  • 1,102
  • 4
  • 17
  • 33
1
vote
1 answer

apollo-client reactjs 404 (Not Found) on client side when use HttpLink

y react app always send post request to http://localhost:3000 and it's throw error like this : createHttpLink.ts:121 POST http://localhost:3000/[object%20Object] 404 (Not Found) It is happen when I try to pass my uri to HttpLink but it's working…
1 2 3
99
100