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.

AWS Lambda support

See original GitHub issue

I’ve been prototyping an API to use with AWS Lambda and this is a basic example of what it could look like:

import { GraphQLLambda } from 'graphql-yoga';

const typeDefs = `
    type Query {
        hello(name: String): String!
    }
`;

const resolvers = {
    Query: {
        hello: (_, { name}) => `Hello ${name || 'World'}`,
    },
}

const handler = new GraphQLLambda({ typeDefs, resolvers });

export const graphql = handler.graphql;
export const playground = handler.playground;

The implementation would be simple to put together for basic use cases, but subscriptions and file-upload would be missing. Binary file-upload is possible already with AWS lambda through API gateway, but if you’re using serverless framework (which I imagine most people are), it doesn’t currently support it as a configuration option. I’ll likely open an issue with serverless to add binary pass-through as an option. Following that, apollo-upload-server would also need lambda support, but that is a trivial addition that I can do.

Subscriptions are the one feature that cannot be entirely handled in lambda. What works instead is having a separate subscription server using express graphql-yoga or some other http server with websocket support and then use remoteSchemaStitching to then have the subscription server resolve queries through the lambda interface.

Looking for some feedback on this approach before anything gets implemented. Thanks!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:12 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kbrandwijkcommented, Jan 5, 2018

Lambda support is released in v0.9.0.

1reaction
chrisl777commented, Dec 4, 2017

Initially, I think in the case of Lambda, it would be great to have support for using a schema string in a local variable, or reading from a local .graphql file. For a Lambda, it is probably better to cache the schema locally, since you get billed for execution time.

Then, later on, you could add support for graphql-config, for the more intensive cases that people may have.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lambda runtimes - AWS Documentation
Lambda supports multiple languages through the use of runtimes. For a function defined as a container image, you choose a runtime and the...
Read more >
What are the AWS Lambda Supported Languages? - Lumigo
What languages does AWS Lambda support? · C# · Go · Java · Node.js · PowerShell · Python · Ruby ...
Read more >
Amazon Lambda – FAQs
Amazon Lambda supports code written in Node.js (JavaScript), Python, Java (Java 8 compatible), and C# (.NET Core). Your code can include existing libraries, ......
Read more >
Amazon Lambda - Quarkus
Quarkus lambdas can be deployed using the Amazon Java Runtime, or you can build a ... Create the Quarkus AWS Lambda maven project...
Read more >
AWS Lambda: The Ultimate Guide - Serverless Framework
What are the most common use cases for AWS Lambda?Task automationSupported LanguagesBenefitsLimitationsPricingFAQGetting StartedImplementing AWS Lambda ...
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