Questions tagged [apollo-server]

Apollo Server is a GraphQL server for Express, Connect, Hapi and Koa, written in TypeScript

Apollo Server is a community-maintained open-source server.

It works with all Node.js HTTP server frameworks: Express, Connect, Hapi and Koa.

Useful links:

2126 questions
10
votes
3 answers

Error: You must `await server.start()` before calling `server.createHandler()` in next.js

I am getting this error when trying to check if apollo graphql is working fine. Error: You must await server.start() before calling server.createHandler() Note : There is a similar question ,but I am not using express Error: You must `await…
Hussam Khatib
  • 600
  • 6
  • 17
10
votes
1 answer

[apollo-engine-reporting]: willResolveField called after stopTiming

We are receiving this error Error: [internal apollo-server error] willResolveField called after stopTiming!, this is leading to unhandled rejection and frequent restart of node server. Any insight to debug this or in what situation it usually…
lofty khanna
  • 111
  • 1
  • 4
10
votes
1 answer

Testing TypeScript with Jest: "no overload matches this call"

I'm working on testing an Apollo Server RESTDataSource using Jest. My app is written in TypeScript. My class, CDCDataSource extends the abstract class RESTDataSource which itself extends the abstract class DataSource. RESTDataSource has the…
Cerulean
  • 5,543
  • 9
  • 59
  • 111
10
votes
3 answers

How do you mock an Apollo Server RESTDataSource for unit testing with Jest?

I'm trying to test a data source in my Apollo Server that based on Apollo Server's RESTDataSource (https://www.apollographql.com/docs/apollo-server/data/data-sources/#rest-data-source). I'm trying to test it using Jest. The class has methods that…
Cerulean
  • 5,543
  • 9
  • 59
  • 111
10
votes
3 answers

How to use passport-local with graphql

I'm trying to implement GraphQL in my project and I would like to use passport.authenticate('local') in my login Mutation Code adaptation of what I want: const typeDefs = gql` type Mutation { login(userInfo: UserInfo!): User } ` const…
Kevin
  • 497
  • 1
  • 5
  • 13
10
votes
1 answer

How to have GraphQL enum resolve Strings

Previously, I just typed my input KeyInput as mode: String!, and I'm looking to change the type from String! to a custom enum. I have the tried following schema: enum Mode= { test live } input KeyInput = { mode: Mode! } type Key { …
Magnum
  • 2,299
  • 4
  • 17
  • 23
10
votes
4 answers

How can I use express middleware with only Apollo Server 2 graphql endpoints

I want to use morgan's tiny log statements for all of my routes, except graphql endpoints. I'm using express and Apollo 2, and have not been able to get middleware working with express. As the code sample shows, I can install middleware for the…
Jared Dykstra
  • 3,596
  • 1
  • 13
  • 25
10
votes
1 answer

How to handle Errors with the Apollo stack

I'm using the Apollo Stack with graphql-server-express and apollo-client. Because my backend is not perfect errors can appear and therefore I have to respond to a request with an error for that path. Till now my main problem was authentication and…
Kordon
  • 254
  • 2
  • 12
9
votes
2 answers

Apollo Server executeOperation with authorization headers

How do we pass headers to Apollo server executeOperation in tests? There is mention about passing a headers object here I'm trying to pass an auth header with or without a JWT token to test access control. const result = await…
Lex
  • 4,749
  • 3
  • 45
  • 66
9
votes
1 answer

How to use Apollo Server DataSource to call a GraphQL API

In our GraphQL api (Apollo-Server) we would like to add a new dataSource which accesses GitHub's GraphQL api. We are looking to consume this data. It appears that using apollo-datasource-rest` is a good approach to do this. It's an established,…
Brettski
  • 19,351
  • 15
  • 74
  • 97
9
votes
2 answers

How do I generate the schema.graphql file when using Apollo Server?

When using Apollo Server to write a GraphQL server, how can I run a command on the server to generate the schema.graphql file for the client to consume? Note: I'm not using the Apollo Client, I'm using Relay. I know I can run the GraphQL playground…
Pablo Fernandez
  • 279,434
  • 135
  • 377
  • 622
9
votes
0 answers

Proxying an Apollo server websocket through API Gateway

I have a GraphQL Apollo server running in AWS Fargate (ECS), I'm using API Gateway (HTTP proxy integration) on top. The purpose of that API is to make use of Cognito Authorizer in addition to secure SSL (HTTPS). This is working fine as far as…
plus-
  • 45,453
  • 15
  • 60
  • 73
9
votes
1 answer

How to pass cookie from apollo-server to apollo-clenet

Mutation Mutation: { signUp: (_, { res }) => { try { res.cookie("jwt", "token", { httpOnly: true }); return "Amasia"; } catch (error) { return "error"; } }; } Apollo-clenet-react const [addTodo, {…
Edgar
  • 6,022
  • 8
  • 33
  • 66
9
votes
3 answers

How to test a GraphQL query providing an auth token with Apollo Server?

Apollo Server Integration testing documentation shows how to test simple queries using createTestClient: const { query } = createTestClient(server); const res = await query({ query: GET_LAUNCH, variables: { id: 1 } }); In the attempt to test a…
Marco Lackovic
  • 6,077
  • 7
  • 55
  • 56
9
votes
2 answers

How to get multiple remote schemas stitched with Nestjs and apollo server

First of I'm rather new at actually posting at Stack Overflow but I will of course try my best to have all the relevant information here AND share the solution once found because I can imagine more people might be having trouble with this. So we've…
Tjeerd
  • 166
  • 1
  • 10