question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@apollo/gateway doesn't work with apollo-server-lambda since 0.9.0

See original GitHub issue
  • Package: @apollo/gateway
  • Version: since v0.9.0
  • Last known working version: v0.8.2

The server crashes with “Error: Expected undefined to be a GraphQL schema” when using new gateway version with apollo-server-lambda.

If you call gateway.load() manually and pass the schema and executor to the ApolloServer constructor, you get “Error: Apollo Server requires either an existing schema, modules or typeDefs”

Here’s a minimal reproducible example:

import { ApolloServer } from 'apollo-server-lambda';
import { ApolloGateway } from '@apollo/gateway';

const gateway = new ApolloGateway({
  serviceList: [
    { name: 'service-a', url: 'http://localhost:4001' },
  ],
});

const server = new ApolloServer({
  gateway,
  introspection: true,
  playground: true,
  subscriptions: false,
  context: ({ event, context }) => ({
    headers: event.headers,
    functionName: context.functionName,
    event,
    context,
  }),
});

exports.graphqlHandler = server.createHandler({
  cors: {
    origin: '*',
    credentials: true,
    methods: 'GET, POST',
    allowedHeaders: 'Origin, X-Requested-With, Content-Type, Accept, Authorization',
  },
});

Here’s what changed between the versions: b0a9ce0…99f78c6 (from a preliminary look gateway.load() seems to be the change that causes the issue).

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
theoribeirocommented, Sep 30, 2019

@trevor-scheer Any updates on this issue?

3reactions
trevor-scheercommented, Aug 23, 2019

@nihalgonsalves thank you for the great issue report and reproduction. I’ve confirmed the bug (and also confirmed it doesn’t happen for apollo-server-express).

I’ll get back to this issue with an update within the week - I’ll need to do some digging and probably pick @abernix 's brain in order to understand what might be going on here, as I’m wholly unfamiliar with lambda. In the meantime, any results of further debugging on your end would be welcomed!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Need help - Updating the apollo gateway from 0.26.1 to 2.0.0
After deploying I got this exception “TypeError: this.node is not a ... update issue”, I have updated the version of graphql to 16.0.0....
Read more >
apollo-server-lambda | Yarn - Package Manager
Apollo Server is a community-maintained open-source GraphQL server that works with many Node.js HTTP server frameworks. Read the docs. Read the CHANGELOG.
Read more >
apollo-server-lambda - CodeSandbox
Saeris/Apollo-Server-Lambda-CodeSandbox-Template. This Sandbox is in sync with master on GitHub. You have to fork to make changes
Read more >
How to Build a Serverless Apollo GraphQL Server with AWS ...
Let's build a serverless Apollo Server and deploy to AWS Lambda!
Read more >
apollo-server-lambda - npm
Production-ready Node.js GraphQL server for AWS Lambda. Latest version: 3.11.1, last published: 2 months ago.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found