Closed ansarizafar closed 4 years ago
@ansarizafar thank you for submitting your request.
We would appreciate if you can provide more context (detail and information) about why we should support GraphQL, please make a case by following our issue template and guidelines.
Your request is very much appreciated.
Would graphql support essentially be support for another "ORM" ? I know there are couple of graphql crystal libraries, but I don't know if either of them are mature.
Currently Amber can use Crecto, Jennifer and Granite successfully.
How differently would be a GraphQL support?
My understanding is GraphQL is not a persistence layer, it's a replacement of a REST API layer.
If I understand the request, You are looking for a GraphQL interface and think Amber would be a good provider of one. You are not the first to request this. It seems to be trending ever since Github provided a GraphQL interface.
https://githubengineering.com/the-github-graphql-api/
When we look at providing a generator for an API and SPA, we can look at providing a GraphQL interface instead of a REST interface.
Yes, GraphQL is not a persistence layer or ORM, it's a replacement of a REST API layer with many exciting features like a single end-point, get all data you need in one request etc. We can also execute Graphql queries/mutations on the server. Graphql server can be used with Relayjs and Apollo client Ver 2 for client-side data caching, offline support and automatic request retries.
Rest APis are past, tech like Graphql/FalcoreJs is the future. I would love to see something like https://www.graphile.org/postgraphile/ in Amber. Just design your schema with Postgresql and Graphile will build a Graphql server with Relayjs/Apollo client support automatically. No need to write Rest/Graphql APIs or authentication/authorization code on your server.
Meanwhile, I am trying to port my Graphql inspired data layer from Nodejs to Crystal with Amber. I call it Restfull RPCs
Best case scenario this is subjective: "Rest APis are past, tech like Graphql/FalcoreJs is the future".
Since amber, rails, phoenix, etc can provide a restful api level doesn't GraphQL make Amber and most frameworks obsolete in a world where REST is the past?
make Amber and most frameworks obsolete in a world where REST is the past?
@elorest I don't believe that. I think common frameworks are adapting to new needs and updating to solve problems using new tools. GraphQL is a good technology, Maybe we can implement this on amber using some template via graphql-crystal or something similar.
@ansarizafar check out Postgrest https://postgrest.com/ as well, similar project: they just expose a schema via http, where even pagination is leveraging http header fields. their authentication jwt story requires some stored procedure tinkering and isn't complete, but overall quite cool and similar in purpose.
RE:graphql in particular, one could create a graphql api with amber, but the same issues that are making it difficult for me to rewrite a legacy app with amber (legacy data from mongo in json requiring a non-id primary-key that's a string/uuid not an int64, as many collections/tables are related via this mongo style _id) are likely going to make collecting various data points for a graphql api difficult. (it's basically a custom multi-db-capable meta-view, in the sql sense) Postgres itself support JSON and JSON types, but the generic ORM approaches are rather inflexible. (being able to add custom sql to any of them would be useful for this purpose!) I think we need ORM-enabled means for collating data and describing an interface for this collation, it should be possible to turn it into a graphql compatible api relatively simply, I would think. (given that this is about expressing a db query from derived client url query params etc...)
In terms of the graphql compatible api itself, that would be fairly easy to generate, given interface specs and models, i would think... but then I'm guessing and the folks here know better about this than I do, seeing as they built this lovely machine!
@vectorselector Thanks you for comment!, We are open to new interesting features, GraphQL is one of them 😉 I was thinking in a simple generator with similar behavior to Kemal+GraphQL example 👉 https://github.com/ziprandom/kemal-graphql-example/
interesting, first time I saw that, I didn't even know about https://github.com/ziprandom/graphql-crystal either. http://facebook.github.io/graphql/October2016/ http://graphql.org/
I'm just finally learning about it now, after being shy of yet-another-cool-shiny-new-hipster-thing and not understanding any use for it...it makes sense now, with aliases, variables, etc.
Idea: http://graphql-ruby.org https://github.com/ziprandom/graphql-crystal Ping to @ziprandom
Closing this in favor of https://github.com/amberframework/amber/issues/1189
Is there any plan to add Graphql support? I would love to see a project like this https://www.graphile.org/postgraphile/ in Crystal.