Questions tagged [apollo]

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

apollo
Filter by
Sorted by
Tagged with
90 votes
16 answers
188k views

GraphQL gql Syntax Error: Expected Name, found }

I'm attempting to set up Apollo GraphQL support in a new React project, but when I try to compile a query using gql I keep receiving the error: Syntax Error: Expected Name, found } This is generated ...
Nathan's user avatar
  • 1,987
70 votes
4 answers
51k views

ActiveMQ vs Apollo vs Kafka [closed]

I don't have any previous experience with *MQs and I'm looking to build knowledge on JMS and message queues in general. That way, I wonder whether I should start with ActiveMQ or just "ignore" it ...
Martin's user avatar
  • 1,325
68 votes
1 answer
43k views

GraphQL: Non-nullable array/list

I'm learning GraphQL now and while walking through tutorial I met behavior that I can't understand. Let's say we have defined type in schema: type Link { id: ID! url: String! description: ...
DefLee's user avatar
  • 695
64 votes
15 answers
30k views

UnhandledPromiseRejectionWarning: Error: You must `await server.start()` before calling `server.applyMiddleware()` at ApolloServer

I am trying to start my nestJs server and It keeps giving me this error: UnhandledPromiseRejectionWarning: Error: You must await server.start() before calling server.applyMiddleware() at ApolloServer ...
Boladek's user avatar
  • 641
64 votes
5 answers
12k views

How do you prevent nested attack on GraphQL/Apollo server?

How do you prevent a nested attack against an Apollo server with a query such as: { authors { firstName posts { title author { firstName posts{ title ...
jboothe's user avatar
  • 1,183
60 votes
3 answers
75k views

Date and Json in type definition for graphql

Is it possible to have a define a field as Date or JSON in my graphql schema ? type Individual { id: Int name: String birthDate: Date token: JSON } actually the server is returning ...
Mohamed Taboubi's user avatar
59 votes
9 answers
105k views

Why I got error: Cannot query field xx on type "Query"?

Although I copied and pasted the graphQL query from the GraphiQL tool after I tested it at GraphiQL successfully , the query returned with an error when I tried it in Apollo client within a reactJS ...
simo's user avatar
  • 23.9k
55 votes
7 answers
44k views

GraphQL dynamic query building

I have a GraphQL server which is able to serve timeseries data for a specified source (for example, sensor data). An example query to fetch the data for a sensor might be: query fetchData { ...
Matt Wilson's user avatar
  • 8,219
48 votes
3 answers
39k views

Apollo/GraphQL field type for object with dynamic keys

Let's say my graphql server wants to fetch the following data as JSON where person3 and person5 are some id's: "persons": { "person3": { "id": "person3", "name": "Mike" }, "person5": { ...
Andru's user avatar
  • 6,044
44 votes
11 answers
48k views

React Apollo - Make Multiple Queries

I have a queries file that looks like this: import {gql} from 'react-apollo'; const queries = { getApps: gql` { apps { id name } } `, getSubjects: gql` {...
user2465134's user avatar
  • 9,293
44 votes
4 answers
72k views

What is the difference between useQuery and useLazyQuery in Apollo graphQL?

I was going through the documentation of Apollo React hooks. And saw there are two queries hooks to use for which is useQuery and useLazyQuery I was reading this page. https://www.apollographql.com/...
Lionel George's user avatar
42 votes
11 answers
63k views

Apollo client: How to simply debug a 400 code error?

I'm using Apollo-client and I don't understand why this is so hard to debug my error: I'm trying to perform a mutate call on my graphene python implementation of GraphQL. It end up with a 400 error ...
Mr Bonjour's user avatar
  • 3,360
42 votes
3 answers
127k views

How to clear/delete cache in NextJs?

I have a product page at /products/[slug].js and I use Incremental Static Generation for a wordpress/graphql site: export async function getStaticProps(context) { const {params: { slug }} = ...
entropyfeverone's user avatar
39 votes
8 answers
63k views

React Apollo Error: Invariant Violation: Could not find "client" in the context or passed in as an option

I'm building a project using React, Apollo and Next.js. I'm trying to update react-apollo to 3.1.3 and I'm now getting the following error when viewing the site. Invariant Violation: Could not find ...
Keith's user avatar
  • 428
39 votes
2 answers
59k views

How to remove the `__typename` field from the graphql response which fails the mutations

I tried changing the addTypeName: false in the Apollo client in GraphQL apollo.create({ link: httpLinkWithErrorHandling, cache: new InMemoryCache({ addTypename: false }), defaultOptions: { ...
Rigin Oommen's user avatar
  • 3,208
38 votes
3 answers
26k views

Using GraphQL Fragment on multiple types

If I have a set of field that is common to multiple types in my GraphQL schema, is there a way to do something like this? type Address { line1: String city: String state: String zip: String }...
Good Idea's user avatar
  • 2,653
35 votes
6 answers
27k views

How to load a .graphql file using `apollo-server`?

I am currently loading the GraphQL schema using a separate .graphql file, but it is encapsulated within strings: schema.graphql const schema = ` type CourseType { _id: String! name: String!...
Sam Sverko's user avatar
  • 1,550
34 votes
3 answers
58k views

Add custom header to apollo client polling request

I am using the apollo-client library to query data from my Graphql server. Some of the queries are sent to the server every 5 seconds through apollo polling ability. Is there a generic way to add a ...
Ron Badur's user avatar
  • 1,943
33 votes
5 answers
39k views

How to refresh JWT token using Apollo and GraphQL

So we're creating a React-Native app using Apollo and GraphQL. I'm using JWT based authentication(when user logs in both an activeToken and refreshToken is created), and want to implement a flow where ...
user3043462's user avatar
32 votes
5 answers
21k views

How to execute an async fetch request and then retry last failed request?

Apollo link offers an error handler onError Issue: Currently, we wish to refresh oauth tokens when they expires during an apollo call and we are unable to execute an async fetch request inside the ...
Mysteryos's user avatar
  • 5,661
32 votes
1 answer
28k views

Should I handle a GraphQL ID as a string on the client?

I am building an application using: MySQL as the backend database Apollo GraphQL server as a query layer for that database Sequelize as the ORM layer between GraphQL and MySQL As I am building out ...
bryan kennedy's user avatar
31 votes
2 answers
26k views

How to chain two GraphQL queries in sequence using Apollo Client

I am using Apollo Client for the frontend and Graphcool for the backend. There are two queries firstQuery and secondQuery that I want them to be called in sequence when the page opens. Here is the ...
afterglowlee's user avatar
31 votes
1 answer
28k views

When to use watchQuery or query in Apollo-Angular?

I am using a watchQuery or query in Apollo-Angular (graphql) How is the logic and difference of the watchQuery and query
yussenn's user avatar
  • 597
31 votes
4 answers
51k views

GraphQL : the object name is defined in resolvers, but not in schema

I want to define a mutation using graphql. My mutation is getting an object as argument. So I defined the new Object in the schema and in the resolver using GraphQLObjectType. However I m getting ...
Mohamed Taboubi's user avatar
31 votes
2 answers
2k views

Stitching secure subscriptions using makeRemoteExecutableSchema

We have implemented schema stitching where GraphQL server fetches schema from two remote servers and stitches them together. Everything was working fine when we were only working with Query and ...
Niks's user avatar
  • 895
31 votes
6 answers
3k views

React Native Android: Fetch Requests only working when React Native Debugger is connected

I have a weird issue with making fetch requests to my API on Android (using React Apollo). In the dev build as well as the release build fetch does not work. As soon as I power up React Native ...
mxmtsk's user avatar
  • 4,505
31 votes
3 answers
2k views

Apollo is not assignable to parameter of type 'VueClass<Vue>

Iam building a 'Nuxt.js' app with typescript. This is my code: <script lang='ts'> import {Component, Vue} from 'nuxt-property-decorator'; import {LOCATION} from '~/constants/graphql/...
Filip Wroński's user avatar
30 votes
1 answer
34k views

Apollo Query with Variable

Just a basic apollo query request this.client.query({ query: gql` { User(okta: $okta){ id } }` }).then(result => { this.setState({userid: result.data.User}); ...
Christian Weisenburger's user avatar
28 votes
3 answers
10k views

GraphQL union and conflicting types

I've got an issue on my project and I can't find any solution on the internet. Here is the situation. I've an Union (DataResult) of 2 types (Teaser & Program) I've a Zone type with a data field (...
Julien Demangeon's user avatar
27 votes
6 answers
20k views

Apollo: You are calling concat on a terminating link, which will have no effect

I am working in Apollo, GraphQL and Nuxtjs project, when setting up Apollo configuration I got this Warning: link.js:38 Error: You are calling concat on a terminating link, which will have no effect ...
Kamal Alhomsi's user avatar
27 votes
7 answers
22k views

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: - C:\Users\Minseo\AppData\...
Minseo Lee's user avatar
27 votes
4 answers
12k views

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 ...
Lin Du's user avatar
  • 95.6k
27 votes
1 answer
10k views

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's user avatar
26 votes
4 answers
28k views

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 ...
user11754604's user avatar
26 votes
5 answers
42k views

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 ...
saeta's user avatar
  • 4,108
24 votes
2 answers
21k views

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 ...
Mario's user avatar
  • 1,233
22 votes
2 answers
6k views

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) ...
John Goofy's user avatar
21 votes
1 answer
12k views

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 ...
Jack M.'s user avatar
  • 1,941
21 votes
4 answers
8k views

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 ...
Bhaumik Gandhi's user avatar
21 votes
3 answers
18k views

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 ...
Le garcon's user avatar
  • 7,607
21 votes
1 answer
2k views

"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 ...
Will Meier's user avatar
19 votes
3 answers
19k views

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): ...
Manan Vaghasiya's user avatar
19 votes
4 answers
29k views

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). ...
Putxe's user avatar
  • 1,064
19 votes
9 answers
12k views

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 ...
Angel F Syrus's user avatar
19 votes
4 answers
15k views

Using multiple endpoints in Apollo Client

this is my first discussion post here. I have learned Apollo + GraphQL through Odyssey. Currently, I am building my own project using Next.js which required fetching data from 2 GraphQL endpoints. My ...
Eugene's user avatar
  • 303
19 votes
1 answer
2k views

Apollo Optimistic UI does not work in Mutation Component?

I am using <Mutation /> 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: { ...
deadcoder0904's user avatar
18 votes
2 answers
16k views

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 ...
iwan's user avatar
  • 7,429
18 votes
5 answers
11k views

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 ...
Kim Gabrielsen's user avatar
18 votes
2 answers
3k views

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 ...
Joshua M Johnsgärd's user avatar
18 votes
3 answers
6k views

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 ...
Mike Lambert's user avatar

1
2 3 4 5
92