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

Running login mutation in utility function instead of component

This question is probably a sign of my misunderstanding of the philosophy of Apollo/React/GraphQL, but I'm a bit stuck here. I am writing the authentication logic for my single page app. I have a backend with a GraphQL API that authenticates users…
Moos Hueting
  • 650
  • 4
  • 14
1
vote
1 answer

How can I force update React.memo child component?

My main functional component performs a huge amount of useQueries and useMutations on the child component hence I have set it as React.memo so as to not cause re-rendering on each update. Basically, when new products are selected I still see the old…
Ashish
  • 31
  • 2
  • 7
1
vote
0 answers

ERR_CONNECTION_REFUSED and Failed to fetch (nodejs, graphql, apollo)

I am newbie on JS frameworks, so sorry if my question is easy but I didn't find any solution on my Google friend :) I am creating a web app with ReactJS in Front-End, NodeJS in Back-End, GraphQL and Apollo. I have my Back-End that works on…
Tiffany
  • 11
  • 4
1
vote
1 answer

Issue with useMutation with await and promise

I am performing the useMutation operation in the innermost loop and want to check the remaining cost upon every mutation. But it gets checked after all the mutations which is a problem because for some reason even if all the mutations get done(When…
1
vote
1 answer

How to prevent error propagation in Apollo Client useQuery in react?

I'd like to catch the error in component level and prevent propagation while using the useQuery in @apollo/react-hook. Here is my example code const invitationDocument = gql` query DecodeInvitation($token: String!) { …
Josh Thomas
  • 1,607
  • 2
  • 8
  • 22
1
vote
1 answer

Unable to resolve "./rules/FieldsOnCorrectType" from "node_modules/graphql/validation/index.js"

I'm building a react native application with apollo client 3, and keep getting the following error when generating the javascript bundle. Failed building JavaScript bundle. Unable to resolve "./rules/FieldsOnCorrectType" from…
JeremyKirkham
  • 1,025
  • 2
  • 11
  • 22
1
vote
1 answer

Apollo GQL - Clear cache for one type only

I would like to be able to clear the cache of only one specified type e.g. if I have Authors and Books I would like to only clear cache for Authors I'm using @apollo/client": "^3.2.5" (latest) Just additional note, shouldn't matter much but I'm…
Stephen Lautier
  • 3,065
  • 3
  • 17
  • 20
1
vote
3 answers

Data becomes undefined in usequery of apollo client only when refreshing the page in the browser

The following code works when it hot reloads the react app. But when I press the refresh button(or press F5), the app crashes saying that the data is undefined. I have already tried the fetch-cache-policies, everyone of them There are no errors in…
Manohar
  • 21
  • 1
  • 4
1
vote
0 answers

Please Help!! How to Use GET for Nuxt Apollo?

The queries are working with POST by default. But I need to change it into GET . And I couldn't figure out apollo: { clientConfigs: { default: { httpEndpoint: process.env.apolloServer, persisting: true, …
Bright Chip
  • 31
  • 1
  • 4
1
vote
1 answer

Nextjs - Children in WPGraphQL query for menus are null

WPGraphiQL IDE displays correct data like this: but when I make the same query with Apollo Client on the Front-End the children of menu returns null. Getting data with query import { useApollo } from "../lib/apolloClient"; import { initializeApollo…
1
vote
1 answer

Does apollo client support transactions?

I have a nuxtjs app that uses apollo module for graphql communication with FaunaDB. I want to make multiple mutations in one transaction to FaunaDB. So I don't want to send a different request for every single mutation to FaunaDB, I want to make a…
Claudia
  • 241
  • 1
  • 2
  • 6
1
vote
0 answers

Testing Apollo Client

I am using Two GraphQL APIs one for data and one for content. Hence using below code to enable this based on https://www.jamalx31.com/tech-posts/using-apollo-with-multiple-graphql-endpoints import { HttpLink, InMemoryCache } from…
Dev
  • 781
  • 9
  • 29
1
vote
1 answer

Apollo client useMutation in expo renders twice for every call

I have a basic expo app with React Navigation. In the top function Navigation I am initiating a useMutation call to an Apollo server like so: import { callToServer, useMutation } from '../graphQL'; function Navigation() { console.log("RENDERED"); …
Ben
  • 2,957
  • 2
  • 27
  • 55
1
vote
0 answers

useQuery in ApolloGraphQL updates the cache when first called, but what about fetchMore?

I'm having trouble nailing how useQuery updates the Apollo Client cache. I observe that when useQuery is first called, what ever is retrieved has __typename added to it, if it's multiple items, they each get there own __typename. What happens when I…
Peter Kellner
  • 14,748
  • 25
  • 102
  • 188
1
vote
0 answers

Am I correct that ApolloClient caches my query, -- even across components -- so useContext isn't necessary?

I have an ApolloClient performing a query through useQuery. I'd like that object to be available to the whole app, without having to re-fetch it from the database. So I was implementing useContext. However, i remembered that ApolloClient caches its…
Iskeraet
  • 731
  • 1
  • 6
  • 12
1 2 3
99
100