Questions tagged [apollo]

Apollo is a GraphQL client and cache for JavaScript, iOS (Swift) and Android.

Apollo is a flexible, fully-featured client for every platform.

Apollo is made up of a family of technologies you can incrementally add to your stack: Apollo Client to connect data to your UI, Apollo Engine for infrastructure and tooling, and Apollo Server to translate your REST API and backends into a GraphQL schema.

It has implementations for JavaScript, iOS and Android. The JavaScript client has integrations for React, Angular, Vue.js, Ember.js and more.

Apollo is fully compatible with any server that implements the GraphQL specification.

4536 questions
26
votes
4 answers

Is graphql schema circular reference an anti-pattern?

graphql schema like this: type User { id: ID! location: Location } type Location { id: ID! user: User } Now, the client sends a graphql query. Theoretically, the User and Location can circular reference each other infinitely. I think it's…
Lin Du
  • 88,126
  • 95
  • 281
  • 483
26
votes
1 answer

What is the difference between buildSchema and makeExecutableSchema

What is the difference between buildSchema from the graphql package and makeExecutableSchema from the graphql-tools package.
Andreas Köberle
  • 106,652
  • 57
  • 273
  • 297
25
votes
5 answers

GraphQL - How to respond with different status code?

I'm having a trouble with Graphql and Apollo Client. I always created different responses like 401 code when using REST but here I don't know how to do a similar behavior. When I get the response, I want it to go to the catch function. An example of…
saeta
  • 4,048
  • 2
  • 31
  • 48
24
votes
7 answers

Error: Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule'

When I run the command apollo client:codegen the following error comes up : Error: Cannot find module 'graphql/validation/rules/KnownArgumentNamesRule' Require stack: -…
Minseo Lee
  • 240
  • 1
  • 2
  • 5
24
votes
4 answers

Is it possible to prevent `useLazyQuery` queries from being re-fetched on component state change / re-render?

Currently I have a useLazyQuery hook which is fired on a button press (part of a search form). The hook behaves normally, and is only fired when the button is pressed. However, once I've fired it once, it's then fired every time the component…
user11754604
  • 273
  • 1
  • 2
  • 6
23
votes
2 answers

What should be the GraphQL mutation return type when there is no data to return?

I have an Apollo GraphQL server and I have a mutation that deletes a record. This mutation receives the UUID of the resource, calls a REST (Ruby on Rails) API and that API just returns an HTTP code of success and an empty body (204 No Content) when…
Mario
  • 1,213
  • 2
  • 12
  • 37
21
votes
2 answers

Generate GraphQL schema from TypeScript?

I have just recently started with Apollo and would like to expose some existing REST APIs through a new GraphQL layer. These REST services are already fully (Request and Response data structures) covered by an extensive set of custom Typescript type…
John Goofy
  • 866
  • 8
  • 22
21
votes
1 answer

How to use apollo-link-http with apollo-upload-client?

Im trying to figure out how to use apollo-link-http with apollo-upload-client. Both create a terminating link, but how could I use those 2 together? In my index.js I have like this, but it wont work because both links are terminating => const…
Jack M.
  • 1,831
  • 5
  • 24
  • 36
21
votes
4 answers

Apollo duplicates first result to every node in array of edges

I am working on a react app with react-apollo calling data through graphql when I check in browser network tab response it shows all elements of the array different but what I get or console.log() in my app then all elements of array same as the…
Bhaumik Gandhi
  • 223
  • 2
  • 6
20
votes
1 answer

"this.getClient(...).watchQuery is not a function" - remote schema stitching with Apollo 2 / Next.js

So I'm attempting to stitch multiple remote GraphCMS endpoints together on the clientside of a Next.js app, and after trying/combining about every example on the face of the internet, I've gotten it to a place that's worth asking about. My…
Will Meier
  • 461
  • 5
  • 12
19
votes
7 answers

How to add header in Apollo GraphQL : iOS

Hy I am working in a project with Apollo GraphQL method and its working fine. But now the client required for adding additional header with Apollo API's. But after adding the header the API's response return as unAuthorized. I am adding the header…
Angel F Syrus
  • 1,984
  • 8
  • 23
  • 43
19
votes
1 answer

Apollo Optimistic UI does not work in Mutation Component?

I am using component which has Render Prop API & trying to do Optimistic Response in the UI. So far I have this chunk in an _onSubmit function - createApp({ variables: { id: uuid(), name, link }, optimisticResponse: { …
deadcoder0904
  • 7,232
  • 12
  • 66
  • 163
19
votes
4 answers

Reset store after logout with Apollo client

I'm trying to reset the store after logout in my react-apollo application. So I've created a method called "logout" which is called when I click on a button (and passed by the 'onDisconnect' props). To do that I've tried to follow this example…
Putxe
  • 1,054
  • 1
  • 16
  • 23
19
votes
4 answers

Graphql-Access arguments in child resolvers

I am using apollo-server and apollo-graphql-tools and I have following schema type TotalVehicleResponse { totalCars: Int totalTrucks: Int } type RootQuery { getTotalVehicals(color: String): TotalVehicleResponse } schema { query:…
Manan Vaghasiya
  • 881
  • 1
  • 10
  • 25
18
votes
3 answers

Apollo mutation debounce and race conditions

(this is a follow up to https://github.com/apollographql/apollo-client/issues/1886) I'm trying to build a text input that will update the value as the user types. First attempt I first tried to use the optimisticResponse to update the local cache as…
Mike Lambert
  • 181
  • 1
  • 4