In our company (eyewear online shop) we’re working with Rest API’s. We’re now doing several things to improve the speed of our store. One thing is to get rid of Rest and use GraphQL instead. A lot of business logic is in PHP behind a Rest API. So we first want to create the GraphQL API. Connect it to database and (whenever its needed) to the Rest API.
I wonder now how this could be done in Absinthe. It must happen somewhere in the resolver. But I could not find any example. Does anyone of you have already done this and can provide me an example, how this could look like? (I’ve used absinthe already successfull with Ecto)
Thank you for your time.
Check out absinthe’s async and batch helpers: https://hexdocs.pm/absinthe/Absinthe.Resolution.Helpers.html
In your resolver you can hit your REST api in a regular http request and the async plugin gives you an easy way to not block the resolution of the rest of the query while the request completes.
At the end of the day, as long as the resolver returns data in the right shape, the source doesn’t matter.
Just wanted to share an alternative solution to GraphQL for these cases.
It provides a similar approach as GraphQL but with existing REST APIs beneath it. It is used on huge e-commerces in production and there is an active team maintaining it.
Could be nice to have an Elixir version of the protocol too, but anyway. This might save you some time perhaps.