aerogear / graphback

Graphback - Out of the box GraphQL server and client
https://graphback.dev
Apache License 2.0
409 stars 73 forks source link

[Discussion] REST data source support using @rest directive #217

Closed wtrocki closed 5 years ago

wtrocki commented 5 years ago

:+1: to vote on issue Comment with alternative ideas

How

Rest directive can be applied to mutation and queries. Applying rest directive will generate source code that will fetch data from remote server using directive url parameters.

@rest(method:"create", path: "/users/create/")

Questions

Base url support - template based vs generation config?

wtrocki commented 5 years ago

I have done quick investigation and from my side this feature do not provide much value to end users. Calling rest will always require some authentication, base url, specific error handlig etc. so it will be hard to make it useful out of the box.

Additionally this will make generation engine complex with little value. What I think we might do instead is to make ability to move standard crud methods that are generated to custom resolvers. This will allow people to drop any requirements they will have including RESTfull calls. From performance side we should cache both custom and generated resolvers.

TL;DR lets allow devs write it themselves.

wtrocki commented 5 years ago

https://medium.com/@Will_Robinson_/apollo-graphql-rest-api-hypnos-f7a7dfd3df47

Worth exploring

wtrocki commented 5 years ago

Closing as our plans moved away from supporting rest gateway this way.