prisma-labs / graphql-framework-experiment

Code-First Type-Safe GraphQL Framework
https://nexusjs.org
MIT License
673 stars 66 forks source link

Add migration guide for Yoga users #667

Open jasonkuhrt opened 4 years ago

jasonkuhrt commented 4 years ago

What

Why

How

homerjam commented 4 years ago

I'd love to drop graphql-yoga and use the built in nexus server, however the current blocker is my lack of understanding how to use graphql-shield with nexus. General documentation for how to use different graphql middleware would be extremely useful here. Perhaps a plugin is required?

Currently the majority of examples in the prisma-examples repo use yoga so again guidance for migrating would be useful and help with adoption of nexus at this early stage.

impowski commented 4 years ago

I would like to see an example too

jasonkuhrt commented 4 years ago

Please +1 the opening comment so that when we order issues by +1 to help prioritize this gets the right visibility. 🙏

homerjam commented 4 years ago

I made this example, it doesn't cover transitioning to nexus server but would serve as a stepping stone for prisma1 users who might be upgrading https://github.com/homerjam/prisma2-example-yoga.

I think having understood everything a bit better now I might be able to change over using the docs here https://www.nexusjs.org/#/api/modules/main/exports/schema?id=middleware. Specifically I was thinking of the middleware being "Express style" and therefore applied to the server/router but actually it's applied to the schema (bit of a GraphQL noob over here).

lvauvillier commented 4 years ago

I just created a plugin to use graphql-shield on your nexus app to help migration from yoga (or other frameworks).

This was not the cleanest solution as we have to keep a dependency of graphql-middleware but it works great with my project without any changes :)

https://github.com/lvauvillier/nexus-plugin-shield