Repository metrics
- Stars
- (10,737 stars)
- PR merge metrics
- (PR metrics pending)
Description
I want to see what the maintainers think about this idea, I'm okay to pursue on this codebase or others first and merge here as well,
Context: We sometimes want REST applications for hotpath since the complexity of query parsing from gateway, then in the subgraph does add some CPU overhead. I know what we do inside of the resolver matters, but there are times when it does make a difference.
Currently, the only option is to create a REST version of the same thing duplicating everything.
Since we have resolver that has the dependency anyway, and we have the AST, what I was thinking is generating the REST automatically using a plugin, and one could enable the plugin and decorate using a specific directive to mark the query/mutation as included in the REST version.
Now the way it'd work is by short circuiting the graphql parsing bit, so it'd be basically:
- REST request matches one of the many handler
- handler gets called,
- handler has body that simply calls your resolver without going through the graphql parsing.
- handler serialize the data it gets and returns it back.
- we can provide (just like AroundFields) a way for people to transform the results into REST results (status codes, etc)
What do you guys think? This way we can simply write a service in GraphQL, and then it can also expose REST, (and potentially also generate grpc as well)