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
18
votes
2 answers

How do you get total contributions with Githubs API v4

I have been looking through the Github V4 API docs and I cannot seem to find a way to query total contributions for the year (as displayed on your github profile). Has anyone managed to use the new API to grab some statistics from your personal…
17
votes
1 answer

Is there a way to detect when data used by a query is evicted from the Apollo Client cache?

Apologies for the long question, but I'd be really grateful for some thoughts/help on the best strategy for cache invalidation & refetching queries in Apollo Client 3. Background First, some information about the scenario I'm imagining: There is…
Matt Wilson
  • 8,159
  • 8
  • 33
  • 55
17
votes
5 answers

How to call GraphQL outside a component

I have made a bunch of React component calling GraphQL using the Query component and everything is working fine. In one component I need to have some initial data from the database, but without any visual representation. I have tried to use the…
Kim Gabrielsen
  • 435
  • 2
  • 6
  • 21
17
votes
8 answers

Network error: Unexpected token < in JSON at position 0 at new ApolloError

const httpLink = createHttpLink({ uri: 'http://localhost:3090/' }) const client = new ApolloClient({ link: httpLink, cache: new InMemoryCache() }) client.query({ query: gql` query users { email } `, }) .then(data =>…
Mukesh Kumar
  • 944
  • 2
  • 10
  • 26
17
votes
3 answers

How to return both error and data in a graphql resolver?

I was thinking about ways of implementing graphql response that would contain both an error and data. Is it possible to do so without creating a type that would contain error? e.g. Mutation addMembersToTeam(membersIds: [ID!]! teamId: ID!): [Member]…
Le garcon
  • 7,197
  • 9
  • 31
  • 46
17
votes
7 answers

Apollo GraphQL Server + TypeScript

I've been working on a project lately, which has node.js + express + typescript + Apollo server stack. And while researching on Apollo client, I've stumbled upon TypeScript section. But nothing like that was for server, which leaves me to freedom of…
naffiq
  • 1,030
  • 1
  • 9
  • 19
17
votes
2 answers

How to run a mutation on mount with React Apollo 2.1's Mutation component?

We are currently moving from Relay to React Apollo 2.1 and something I'm doing seems fishy. Context: Some components must only be rendered if the user is authenticated (via an API key), so there is an Authenticator component guarding the rest of the…
astorije
  • 2,666
  • 2
  • 27
  • 39
17
votes
2 answers

Apollo Client (React): Handling unexpected errors

I have been reviewing the Apollo documentation but I do not see information of how to go about handling server errors in the Apollo client. For example, suppose that the server either: Times out Becomes unreachable Unexpectedly fails How…
dipole_moment
  • 5,266
  • 4
  • 39
  • 55
16
votes
1 answer

TypeError: String cannot represent value: graphql Query not working

I am trying to run a graphql Query but it keeps giving me the "TypeError: String cannot represent value:" error. The schema for my query: type User { active: Boolean! email: String! fullname: String! description:…
Kaisin Li
  • 514
  • 3
  • 7
  • 21
16
votes
1 answer

Unsubscribe subscription in Apollo Client

In my component, I have this code: componentDidMount () { // Setup subscription listener const { client, match: { params: { groupId } } } = this.props client.subscribe({ query: HOMEWORK_IN_GROUP_SUBSCRIPTION, variables: { groupId }, …
V0iDiFiER
  • 165
  • 1
  • 1
  • 4
16
votes
2 answers

How to pass a variables for refetchQueries in Apollo

I am not sure what the best practice is to pass variables in refetchQueries options. In below example the variables is {id: this.props.item.id} But passing this.props.item.id returned an error since MyComponent is not yet instantiated hence…
iwan
  • 7,269
  • 18
  • 48
  • 66
16
votes
6 answers

Multiple Queries/Mutation in Apollo 2.1

I need some help using the new Query and Mutation component in Apollo 2.1, especially with multiple queries and mutations. I have the following problems: I have a graphql request that depends on a previous graphql result, how can I deal with…
brunodahora
  • 331
  • 1
  • 3
  • 6
16
votes
2 answers

GraphQL how to avoid duplicate code between input and output types

I'am new to GraphQL but I really like it. Now that I'am playing with interfaces and unions, I'am facing a problem with mutations. Suppose that I have this schema : interface FoodType { id: String type: String composition: [Ingredient] …
Fred Mériot
  • 4,157
  • 9
  • 33
  • 50
16
votes
2 answers

How to send GraphQL mutation from one server to another?

I would like to save some Slack messages to a GraphQL backend. I can use the Slack API and what they call "Slack App Commands" so everytime a message is send to my Slack channel, Slack will automatically send a HTTP POST request to my server with…
Damien Monni
  • 1,418
  • 3
  • 15
  • 25
16
votes
1 answer

GraphQL use field value as variable for another query

I'm querying for 2 objects which are both needed in the same component. The problem is that one of the queries have to wait on the other and use its id field as an argument for the other. Not sure how to implement this. const PlayerQuery = gql`query…
Nick Dima
  • 1,587
  • 2
  • 18
  • 36