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:

1540 questions
9
votes
3 answers

How to handle cookies inside apollo-server-lambda

set cookies inside a lambda serverless with apollo-server-lambda I am migrating from apollo-server to the serverless version. Is there a way I can access the response object or another way to set cookies? context: ({ event, context }) => ({ …
Popa Alex
  • 175
  • 7
9
votes
0 answers

ApolloGraphQL: Non web socket subscriptions?

We have an app that implements essentially this guide exactly: https://www.apollographql.com/docs/apollo-server/features/subscriptions/ It's been great. We've had great success and the app has been doing great. What we have started running into…
sauce
  • 572
  • 3
  • 8
  • 22
9
votes
3 answers

Apollo Server: dataSources vs context to use it with database

After see this documentation I'm not sure if to use a simple context, as I has done other times, or if it is better to use dataSources to handle the database. DataSource is the correct way to comunicate with the database or it is better use it only…
xeladejo
  • 560
  • 4
  • 15
9
votes
2 answers

ApolloServer.applyMiddleware({ express }) getting UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'use of undefined

const { ApolloServer, gql } = require('apollo-server-express') const express = require("express"); const next = require("next"); const dev = process.env.NODE_ENV === "development"; const app = next({ dev }); const handle =…
9
votes
1 answer

Subscription not connecting using ApolloServer

I am trying to get a subscription up and running with ApolloServer (v 2.2.2). I had a setup that all-of-a-sudden just stopped working. When I try to connect to the subscription in graphiql/PlaygroundI get the error: { "error": "Could not connect…
Max Gordon
  • 4,888
  • 1
  • 37
  • 63
9
votes
1 answer

Tracking online user with GraphQL Apollo

I need to handle events "user is now online" and "user is now offline" on GraphQL Apollo Node.js server. What's the best way to do it? My investigation: I pretty sure that I don't need to implement any heartbeat logic, because subscriptions are…
Andrew Gura
  • 342
  • 2
  • 10
9
votes
5 answers

apollostack/graphql-server - how to get the fields requested in a query from resolver

I am trying to figure out a clean way to work with queries and mongdb projections so I don't have to retrieve excessive information from the database. So assuming I have: // the query type Query { getUserByEmail(email: String!): User } And I…
Vikk
  • 537
  • 6
  • 16
8
votes
1 answer

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
  • 3,591
  • 31
  • 63
8
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-
  • 40,996
  • 14
  • 55
  • 71
8
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
  • 377
  • 1
  • 4
  • 10
8
votes
1 answer

Is it possible to have partially federated gateway?

I'd like to federate services, but let the federation gateway also hold own schema and logic that would proxy REST API endpoints for simplicity. Now it looks like I need to have federation gateway service, federated graphql service(s) and the…
Ville
  • 372
  • 2
  • 12
8
votes
1 answer

How to use 'Decimal' as a field type in GraphQL schema?

I want to use Decimal as a type for latitude & longitude field in my GraphGL schema. But GraphQL provides only Float and Int. Is there is any package to solve this?
Debotos Das
  • 178
  • 3
  • 13
8
votes
2 answers

Apollo Server Slow Performance when resolving large data

When resolving large data I notice a very slow performance, from the moment of returning the result from my resolver to the client. I assume apollo-server iterates over my result and checks the types... either way, the operation takes too long. In…
sergelerner
  • 349
  • 3
  • 12
8
votes
2 answers

CORS preflight response doesn't match actual response

In my node.js server I have included CORS as middleware like so: app.use(cors({ origin: 'http://:3030', credentials: true })) I'm using Apollo Client in the app that sends the request, and have set credentials to 'include' when…
Jake
  • 2,200
  • 2
  • 18
  • 41
8
votes
3 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,487
  • 10
  • 24