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

express-graphql as serverless? #57

Open
gpbaculio opened this issue Jan 20, 2021 · 2 comments
Open

express-graphql as serverless? #57

gpbaculio opened this issue Jan 20, 2021 · 2 comments

Comments

@gpbaculio
Copy link

I am introducing my self to serverless and came here but can't seem to understand what's difference with serverfull deployed to heroku? see i have this code in serverless:

app.use(
  "/graphql",
  graphqlHTTP(async (request) => {
    // add user context
    console.log("test");
    return {
      schema,
      graphiql: true,
      context: {
        request,
        //user
      },
    };
  })
);

module.exports = app;

and serverfull:

app.use(
  "/graphql",
  graphqlHTTP(async (request) => {
    // add user context
    return {
      schema,
      graphiql: true,
      context: {
        request,
      },
    };
  })
);

app.listen(port, () => console.log(`Listening on port ${port}`));

can somebody tell me if there's an advantage using serverless in express-graphql? my frontend stack is graphql-relay and i am used to express-graphql and want to explore serverless using express-graphql stack but can't seem to find a good resource to do it. as i am reading from this:

At this point, I think it’s worth noting that not everyone agrees that running Express in a serverless function is a good idea. As Paul Johnston explains, if you’re building your functions for scale, it’s best to break each piece of functionality out into its own single-purpose function. Using Express the way I have means that every time a request goes to the API, the whole Express server has to be booted up from scratch — not very efficient. Deploy to production at your own risk.

please clarify me, i don't see graphql in your samples atm

@eahefnawy
Copy link
Member

Have you considered using the graphql component instead? It's powered by AWS AppSync, so you wouldn't need express, or any servers for that matter.

@gpbaculio
Copy link
Author

i don't think appsync supports graphql relay in a good way, there's a small itch i cannot scratch on pagination

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

2 participants