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.

[Feature request] Support Zeit Now v2 lambda

See original GitHub issue

First of all I’d like to thank you for this awesome project!

I’d like to ask you to support Now v2 lambdas. Their lambdas have a different signature than AWS. It’s like this (more info here):

const { parse } = require('url')

module.exports = (req, res) => {
  const { query } = parse(req.url, true)
  const { name = 'World' } = query
  res.end(`Hello ${name}!`)
}

It seems for me that returning “app” at this point and just exporting as module.exports would do the job. https://github.com/prisma/graphql-yoga/blob/master/src/index.ts#L351

The idea is to create another function on the server, maybe createExpressApp or something that would return the configured express server and receive the same Options as createHttpServer receives. This function would be used on createHttpServer up to the line 351.

I’ll submit a PR for it later. Thanks 👍

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:6

github_iconTop GitHub Comments

1reaction
lucasavila00commented, Aug 31, 2019

Use my fork if you want: I use it on production and it works fine https://github.com/lucasavila00/graphql-yoga/ https://www.npmjs.com/package/graphql-yoga-dgt

Usage:

// src/index.ts
import { GraphQLServer } from "graphql-yoga-dgt";
import resolvers from "./resolvers";
import options from "./options";

const server = new GraphQLServer({
  typeDefs: "/schema.graphql",
  resolvers: resolvers,
});

// same options as server.createHttpServer receives
module.exports = server.createExpressApplication(options);

// now.json
{
  "version": 2,
  "builds": [
    {
      "src": "/src/index.ts",
      "use": "@now/node"
    }
  ],
  "routes": [
    { "src": "/api", "dest": "/src/index.ts" }
  ]
}

If any mantainer likes this approach feel free to implement this or ping me for a PR

0reactions
TheDSCPLcommented, Nov 28, 2019

@lucasavila00 Conseguiu pôr isto a funcionar?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ability to build for zeit/now serverless functions · Issue #16 ...
Feature request : Ability to build for zeit/now serverless functions #16 ... on 2 linux boxes (my local and remote lambda builder.).
Read more >
Zeit Now v2 workflow - Gleb Bahmutov
If we have a hundred separate lambdas, how do we provide uniform API endpoints? We can define a routing structure on top of...
Read more >
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 >
Firebase + Lambda + Zeit now - Remy Sharp
I've been playing with Zeit's v2 now platform, and in particular I ... AWS lambda with Now uses node@8.10 - ensure your modules...
Read more >
Goodbye Zeit Now v1, hello datasette-publish-now—and ...
I first started experiencing with Zeit's serverless Now hosting ... v2 is built on top of serverless functions—AWS Lambda in particular.
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