prisma-labs / yoga2

A lightweight 'Ruby on Rails'-like framework for GraphQL
https://www.graphql.yoga
MIT License
347 stars 15 forks source link

What GraphQL server should we bundle into yoga2 ? #12

Open wtrocki opened 5 years ago

wtrocki commented 5 years ago

Motivation

When trying to implement a GraphQL server for node.js, developers often need to make a decision about what implementation they can use (from a wide range of options including yoga1). The most popular options are:

Pros/Cons of using Apollo Server

Pros

Cons

Pros/Cons of express-graphql

Pros

Cons

Open questions (transcript)

1) Should yoga provide an abstraction for server-side implementation? 2) Should decision about framework implementation be done inside template/sample app leaving yoga to be fully independent to actual API framework? 3) What should be default option (Express based ApolloServer? anything?) 4) How to handle situations when users will want to add yoga to their existing package when using specific framework?

Any thoughts is appreciated 🙌

pantharshit00 commented 5 years ago

I think we should use express as the underlying server:

  1. Express has the most mature and vast system of middlewares. That will allow for the customizability that most users will need
  2. The express API of yoga1 was one of the main feature of it. Some people still use yoga 1 for the same reason as it makes using express middlewares a lot easy.
  3. If we don't expose the API we will have some trouble making things like sessions and cookies to work properly while using express even we can use these as an implemention detail and expose a better api. There will be a new adoption pattern as well.

Using Koa will also be an interesting option here as Koa is faster than express but most people don't know the gist of koa.

For now I think leveraging apollo-server-expess will be an good option. We can also consume the express graphql which is built by official graphql team as we use Nexus to build the schema. That way we can get rid of Apollo engine in dependencies which is not required by us and it will be easier to expose the API as well

vanthome commented 5 years ago

I'm for koa :)