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

getStaticProps returns an empty object

I'm using nextJS V9.5.5 with wp-graphql and apolloClient to get data from WordPress. Everything works fine, but when I try to return context (in the purpose of getting query) from getStaticProps() like it's described in docs, it returns an empty…
1
vote
0 answers

Error: Response not successful: Received status code 400 @apollo/client and GraphQl

While trying to run a GraphQL mutation using apollo/client I am getting an error. I tried the same query from GraphQL playground and it worked fine. I also run a GraphQL query from my app, that also worked fine. I read here that the 400 error is…
Ben Jonson
  • 565
  • 7
  • 22
1
vote
0 answers

How to merge cached data which are different field but same query in Apollo-React?

My first Query was : const krxStockCloseQuery = gql` query getKrxStock($code: String!, $start: String, $end: String){ krxStock(code: $code, start:$start, end:$end){ date close } } `; And cached data…
1
vote
1 answer

React ApolloClient useQuery fetches data twice

I use a simple useQuery: const {data, loading, error} = useQuery(LISTINGS, { variables: { page: page, limit: LISTINGS_LIMIT, sort: sort } }); But I noticed that /api is called…
Mintis
  • 51
  • 2
1
vote
0 answers

Better way to handle conditional query in apollo graphql react

I am using @apollo/client and have a set of queries in a component, and I need to call them conditionally. ex : const { data: userTypeOneData, loading: userTypeOneLoading, error: userTypeOneError } = useQuery< UserTypeOneQuery, …
Bobby
  • 4,372
  • 8
  • 47
  • 103
1
vote
0 answers

why wouldnt Apollo client re-render UI after successful cache register?

Just like the screenshot below, I am trying to add a task to my db and render it out on the client side as it updates. It does successfully readQuery and normalize the cache with my db, and adds to cache as below screenshot. The problem is the…
paul.kim1901
  • 341
  • 4
  • 15
1
vote
2 answers

Unhandled Rejection (Error): Post must not be empty

I'm handling the error with useMutation error handling method however after i attempt to test the error handling by posting an empty post it shows the error in the UI then right after the app breaks and i get the error above. const [createPost, {…
Abdelwahab
  • 149
  • 9
1
vote
0 answers

Updating cache after delete mutation using React, Apollo, GQL, Hasura

For reference, this is what I've been trying to accomplish: https://hasura.io/learn/graphql/react-native/update-delete-mutations/4-remove-todos-integration/ I've been stuck trying to figure out how to solve this problem. I have a page with a list of…
TheWolf1494
  • 96
  • 1
  • 6
1
vote
1 answer

Propagate ApolloError to client

I have real hard time to get custom Apollo error on the client side. Here is the server code: ... const schema = makeExecutableSchema({ typeDefs: [constraintDirectiveTypeDefs, ...typeDefs], resolvers, schemaTransforms:…
1
vote
1 answer

cannot import graphql query files in jest vue

I adding unit tests to my Nuxt/Vue project and I'm using Jest for unit testing, I'm fetching data from the server-side using Apollo Client and I have a problem with importing .gql files inside test files. here is the query file names.gql { names { …
1
vote
1 answer

Does Apollo cache the returned data from a mutation

I'm using Apollo Client in a React app and I need to do a mutation then keep the returned data for later use (but I won't have access to the variables ), do I have to use a another state management solution or can we do this in Apollo? I've read…
Mel
  • 625
  • 9
  • 25
1
vote
2 answers

Variable "$picture" of required type "Upload!" was not provided

I am trying to upload file with apollo-upload-client from Next.js app to Node.js back end using graphql. My Apollo client config const createClient = (ctx: NextPageContext) => new ApolloClient({ credentials: "include", headers: { cookie: …
Good Guy
  • 95
  • 1
  • 9
1
vote
1 answer

How do I solve the "Could not find "client" in the context..." issue for Apollo?

Error message: Could not find "client" in the context or passed in as an option. Wrap the root component in an , or pass an ApolloClient instance in via options. Does anyone know how to solve this issue? useQuery(LINK_QUERY) is…
peyo
  • 351
  • 4
  • 15
1
vote
0 answers

Proper way of refetching queries after mutation in React + ApolloClient project

Creating an app which allows you to sign up and sign in user in the database. After sign up / sign in process the app moves you to the content. Code for authorization process: const Auth = ({ handleSetAuthorized }) => { const { refetch } =…
rgdzv
  • 433
  • 5
  • 18
1
vote
0 answers

Apollo GraphQL appends duplicates to component state

I have a page that contains a component that renders a list from the results of a query. When I load the page the first time, the list renders fine. But whenever I go to another page and navigate back, an additional set of the result is appended to…