3,364 questions
Best practices
0
votes
0
replies
34
views
Apollo Client Cache Update Strategy for new object mutations
I’m trying to find an effective way to introduce newly created “second class” objects into the InMemoryCache. By “second class”, I mean objects that depend on a parent object. When I’m creating these ...
0
votes
0
answers
63
views
React Native Release APK works locally but breaks on Play Store with "undefined is not a function" Apollo Client error
My React Native app (v0.79.5) with Apollo Client works perfectly when testing locally with release APK, but when uploaded to Google Play Console and downloaded from the Play Store, I get consistent ...
-1
votes
1
answer
163
views
How to fix Apollo Client v4 in Expo?
I have a problem with migrating from Apollo client v3 to v4 and i get this error
Warning: Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite ...
1
vote
0
answers
154
views
Why am I getting a CORS error with Apollo Client using credentials: "include"?
I'm building a React app with Apollo Client and a Node.js backend (Apollo Server).
My Apollo Client setup looks like this:
const httpLink = createHttpLink({
uri: "http://localhost:4000",
...
1
vote
1
answer
364
views
Generated file uses skipToken import incorrectly in Next.js App Router
I’m using Apollo Client v4 (4.0.5) with Next.js App Router and GraphQL Code Generator (typescript-react-apollo) to generate TypeScript types and hooks for my GraphQL API.
Everything was working fine ...
0
votes
0
answers
57
views
How do I use cookies for authentication when using ApolloClient and NextJS
I am working with a NextJS project that needs to access a graphql API. I am using the nextjs app router and am trying to follow the best practices outlined here https://github.com/apollographql/apollo-...
0
votes
1
answer
106
views
is it possible to generate typing for the cache object of apollo client mutation?
I’m using graphql-codegen with apollo-client. Everything works great except one thing:
I tried to update cache after mutation, the update function of client.mutate doesn’t have typings for the cache ...
-1
votes
1
answer
132
views
How do I clear apollo errors that fill the console when running Cypress tests
Since sometime recently, possibly from upgrading to apollo 3.9.9 or from switching to mocking with graphql-codegen (not sure which if either), the console of my developer tools now fills up with ...
2
votes
1
answer
274
views
Inserting ' $fragmentrefs` into generated types when using Apollo GraphQL fragments
I recently started using Apollo Fragments for the first time to synchronize parts of schemas between queries and mutations instead of manually keeping those schemas synchronized.
However, now ...
0
votes
1
answer
81
views
Apollo Client Query Doesn't Update After Updating Reactive Variable
Several of my Apollo Client query's variables are mutable depending on different user actions (search input, category filtering, pagination, etc.). I figured the best way to handle this was to use ...
1
vote
1
answer
197
views
Cannot import @apollo/client in Vinxi/Vite/Tanstack Start
The following line works fine in the browser and in Bun:
import { ApolloProvider } from "@apollo/client";
but when I run it in SSR (inside Tanstack Start / Vite / Vinxi) I get an error ...
0
votes
2
answers
223
views
Apollo client cache not being reset after calling client.resetStore()
I am getting an unexpected behaviour. That is, I have put a skip condition in the query and even when the skip condition is supposed to be true, the query is being run. I have made a minimal ...
0
votes
0
answers
48
views
useQuery with useEffect not causing infinite re-render
I have below code snippet:
const [state, setState] = useState(null);
{data, loading, error} = useQuery(SOME_QUERY, {fetchPolicy: 'no-cache'});
useEffect(() => {
setState(data)
}, [data]);
This ...
1
vote
1
answer
133
views
Parse JSON response to apollo-client query
How can I parse a stored JSON response in React and pass to a component that is expecting graphQL response?
Is there a way to add the __typenames from the query RatingQuery?
This is what I am trying, ...
1
vote
2
answers
271
views
getting cookies from apollo client on next js
I want to get the cookie with my client component, but somehow, it always return undefined or empty string. I am using js-cookie since someone recommend it.
ApolloProviderClient.tsx:
"use client&...
0
votes
1
answer
39
views
setContext not setting the token call before API call when token expires
Token API should get called before the GraphQL API but it's being called at the same time
I am fetching the headers inside setContext
Inside commonAuthHeaders I am calling the API to get refresh token
...
1
vote
1
answer
88
views
Apollo client cache returns a bad data
First, I call useGetData with parameters that include filters for test1 and test2 (this is correct). The data is fetched and stored in the cache. Then, I disable the test2 filter and make a new ...
1
vote
0
answers
16
views
Cannot throw specific error to the frontend from backend in apollo/spring app
I want to throw a custom exception from the my reactive spring-boot backend to the browser front end over graphql apollo. I want to front end browser to know about the specific information in this ...
0
votes
1
answer
143
views
Getting "reobserveAsConcast is not a function" error after updating to Apollo Client 3.12.0
I recently updated my Apollo Client version from 3.5.8 to 3.12.0, and now I'm encountering an error when using the useLazyQuery hook. The error states:
observable.reobserveAsConcast is not a function
...
1
vote
0
answers
55
views
Unknown logs in registered persisted query
I am trying to implement registered persisted query. when i am running a query which is not there in my PQL, with apq as enabled it is logging the query in router logs with error code “...
0
votes
1
answer
97
views
Vue 3 apollo client UseLazyQuery for multiple results
I am trying to run the useLazyQuery in my vue to get data from Apollo client. I am passing the parameter and query return different results based on the parameter being passed.
My issue is that result ...
1
vote
2
answers
1k
views
Why does a new Angular 19 app error when executing ng add apollo-angular?
I'm trying to add apollo-angular to my Angular 19 project, but I'm getting the following output in the terminal:
We couldn't find 'esnext.asynciterable' in the list of library files
to be included in ...
0
votes
1
answer
288
views
How to implement cursor based pagination when elements can be deleted, which can invalidate the stored cursor?
I have a GraphQL query which looks like so
query Person($cursor: ID, $limit: Int) {
items:{
...
}
name
...
cursor
}
While making the query for the next page, I fetch using the returned ...
0
votes
3
answers
177
views
Is Apollo client polling 'long' or 'short'?
I can't see anything in the Apollo docs to suggest whether the Apollo client implements short or long polling - can someone please confirm(?)
0
votes
1
answer
58
views
After some requests it losts the cookies and gives GraphQL Error "Cannot read properties of undefined (reading '_id'). "
I am using Query and resolver for fetching the articles data. In one request it fetches the 15 records. Fetching data limit is 15. After some request it lost the user Info/cookies an gives error ...
0
votes
1
answer
185
views
Pagination of Data with Apollo GraphQL and SSR NextJS pages
I am using Next.js v14, graphql, ApolloClient and ApolloGraphQL Experimental support for NextJS
{
"@apollo/client": "^3.12.0-rc.3",
"@apollo/experimental-nextjs-app-...
1
vote
0
answers
68
views
apollo-client-maven-plugin: How to flatten fragments in generated models
I'm using the apollo-client-maven-plugin version 7.1.0, and I'm trying to flatten fragments in my response models, but I'm encountering an issue where the fragments are wrapped in a nested object.
...
0
votes
1
answer
249
views
Data Retrieval not getting updated until after a few requests in my Apollo GraphQL request
I have this weird issue in my react application. My graphQL request does not seem to be fetching the most recent data even when the graphQL server returns the data. I am not really sure what is going ...
1
vote
1
answer
769
views
NextJs Error at build: ApolloError: Dynamic server usage. Couldn't be rendered statically because it used revalidate: 0 fetch
When we build nextJs yarn build when it goes to the step Generating static pages we have this error:
Error occurred prerendering page "/partners/partner-with-us". Read more: https://nextjs....
0
votes
1
answer
150
views
Cannot mock useMutation using MockProvider
I have been using MockProvider from Apollo Client successfully in mocking normal GQL queries, but when I try to mock mutations it does not seem to work.
If I try to mock a useMutation using the ...
3
votes
1
answer
1k
views
Why does querying Strapi with "DRAFT" status return both published and drafted items in GraphQL?
I'm using Strapi as a headless CMS with the Draft & Publish feature enabled, and I'm querying the data using GraphQL in my project. The problem I'm facing is with filtering drafted and published ...
1
vote
0
answers
223
views
502 Bad Gateway Error when Switching Pages in Next.js with Apollo Client Setup
I'm encountering a 502 Bad Gateway error when switching between pages in my Next.js application that uses Apollo Client. Here’s a brief overview of my setup:
import { ApolloClient, HttpLink, ...
0
votes
1
answer
515
views
apollo useSuspenseQuery causes non-stop rerenders
I have the below component -LocationStats- running a suspense query. The query causes non stop re-renders. I can see it sends a query to the server, and the minute it gets a response, it launches the ...
0
votes
1
answer
50
views
Can I use Apollo refetchQueries with a different client
We are in the process of migrating some calls from one server to another. I currently have an existing call that works with refetchQueries
const refetchQueries = ['MyComponent', { query: MY_QUERY, ...
0
votes
1
answer
50
views
Apollo Client is refetching a query after an add mutation but not a delete
I have a mutation that adds a todo to a list of todos.
mutation AddTodo($data: AddTodoInput!) {
addTodoToList(data: $data) {
id
todos{
...
0
votes
1
answer
85
views
Apollo Client. Why mutation "update" callback is called with unmodified cache second time?
I am trying to use cache.modify to update a field after mutation. This is reactions field of my Message model. The mutation removes reaction from the reactions field. I am using optimistic response.
...
0
votes
1
answer
240
views
Use GraphQL Documents on Apollo Client queries
I have created a Rest API application in Typescript, using NestJS and querying a GraphQL server using Apollo Client.
I currently have my queries hard-coded like this:
const query = "query { ...
0
votes
1
answer
263
views
How to run a GQL Query against mock data to get realistic results in unit tests?
I’m looking for a way to run a query against a mock data object.
The problem
I currently mock the GQL response via . That works great, but the mock’s result comes back exactly as defined. The mock ...
1
vote
1
answer
44
views
Unable to call getStaticProps
I am trying to fetch menu items from WordPress through Apollo client, but my getStaticProps function never gets called.
Here is what I currently have as my setup:
Navbar.jsx src/components/Navbar
...
0
votes
0
answers
251
views
How to resolve recursive objects with the Apollo client's cache read function
I have a tree like structure in my backend described by the following GraphQL schema. Since dynamic recursion is not possible each node just contains the numerical id of it's parent but not the object ...
0
votes
2
answers
215
views
Set header in graphql
I want to set auth in req header to specific value but after I tried different methods and check req from browser my key is not in the req header
I am using Reactjs ,vite ,@apollo/client and running ...
1
vote
1
answer
692
views
Vite build problem with tslib.es6.mjs (Uncaught TypeError: R2 is not a function)
I have a React App setup in an npm workspace
/apps
/fe-app
/common
/common
/common-fe
common-fe depends on common
fe-app depends on common-fe
previously I used CRA with babel/webpack to ...
-1
votes
1
answer
106
views
'npm run dev' result: [Error: ENOENT: no such file or directory, open '/ddev/project-name/node_modules/@vue/apollo-composable/src/useApolloClient.ts']
I took over a Craft CMS project, which I successfully upgraded to the latest version of Craft 5.
When I run the command needed to build the JS and CSS files
npm run dev
I get the following error:
...
0
votes
1
answer
142
views
Datasource is undefined when running the Apollo GraphQL server
I am getting datasource undefined on resolvers when trying to query getTracking.
I have a FedexAPI class that extends RESTDataSource from "@apollo/datasource-rest" as a Data source.
The ...
0
votes
1
answer
865
views
Apollo client + zustand?
I’m currently working on a personal sports tracking project using React Native and GraphQL, and I’m wondering about the use of Apollo Client in combination with Zustand.
Apollo Client handles data ...
0
votes
1
answer
34
views
undefined is not a function. Graphql + apollo + react native
In my react native project I'm using graphql codegen to generate types and hooks. I'm using react native 0.74.5. But I don't know why I have an error, so that is why I can't launch my app.
also here ...
0
votes
1
answer
521
views
Apollo Client Caching Issue with fetchPolicy: 'no-cache' in Next.js Server Component
I'm working on a Next.js server component to fetch events from a GraphQL server, but I'm encountering an issue where the cache seems to be used despite setting fetchPolicy: 'no-cache'. Here is my ...
1
vote
1
answer
230
views
Best practise to typePolicies with Apollo
I want to have centralized client-only fields.
Example:
Server:
type Name {
first: String
last: String
}
type User {
name: Name
}
Client:
extend type User {
fullName: String!
}
import { ...
1
vote
1
answer
28
views
GraphQl is not able to execute mutation with apollo
I have given mutation query for adding book details. I have to accept 3 params dynamically. this is my bookQuery.js
const ADD_BOOK = gql`{
mutation ($name: String!, $genre: String!, $authorId: ID!)...
0
votes
1
answer
357
views
Apollo Client is not using cached data and instead makes a network request
I have this weird behavior that I've been wrapping my head around for the past couple of hours.
Let's consider these two queries as examples:
A query that returns and array of authors
query Authors {
...