Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Support Zeit Now v2 lambda #537

Closed
lucasavila00 opened this issue Feb 20, 2019 · 6 comments
Closed

[Feature request] Support Zeit Now v2 lambda #537

lucasavila00 opened this issue Feb 20, 2019 · 6 comments

Comments

@lucasavila00
Copy link

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 👍

@Gruneau
Copy link

Gruneau commented May 24, 2019

Any news on this? Would love to keep using graphql yoga with zeit since it was so simple for me to maintain / deploy

@notrab
Copy link
Contributor

notrab commented May 24, 2019

Great issue! I'm not sure how this version of Yoga could continue to do what it does + support Now 2. Yoga currently enables subscriptions, which Now can't support, amerite?

@lucasavila00
Copy link
Author

lucasavila00 commented Jun 30, 2019

@notrab You're right.
It doesn't support subscriptions because of how serverless functions are modeled.
But it doesn't stop us from using this in any way. The only problem is what I described in the issue.
I'm waiting for it to merge still #538

@stale
Copy link

stale bot commented Aug 31, 2019

Due to inactivity of this issue we have marked it stale. It will be closed if no further activity occurs.

@stale stale bot added the status/stale label Aug 31, 2019
@lucasavila00
Copy link
Author

lucasavila00 commented 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

@TheDSCPL
Copy link

@lucasavila00 Conseguiu pôr isto a funcionar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants