Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apollo Angular Link REST #1184

Open
rfreydi opened this issue May 3, 2019 · 0 comments
Open

Apollo Angular Link REST #1184

rfreydi opened this issue May 3, 2019 · 0 comments
Labels
feature New addition or enhancement to existing solutions

Comments

@rfreydi
Copy link

rfreydi commented May 3, 2019

Hi everyone,

I'm currently dealing with some issue about caching response and traversing of REST API's backend (even with HATEOAS). I didn't want to implement NGRX/NGXS as it has a lot of stuff to implement with (already done in a previous professional project) and I prefer to move on Apollo and give it a shot. I found that there is a apollo link rest and tried it. I had some trouble to set the HttpClient of Angular instead of the Fetch API (through the customFetch parameter). If you directly give the httpClient.get(..., {observe: 'response'}).toPromise() somewhere in the code it crash by saying that response.clone().json() is not a function.

Beside that I found not really convenient to write @rest in each query we need to do against the REST endpoint. I would prefer having it transparent through a configuration that you pass to the RestLink. It prevent you and new developer to know which resource need to hit the REST API and it also prevent to refactor all queries if the backend decide to adopt GraphQL.

I started to create a RestLink based on the apollo angular link http implementation by adding an endpoints option to specify all keys that are REST API resources and also a mapper to be able to transform the REST API response before giving it to the Apollo (if you use JSON-LD, HAL, ... to format your API response you don't need to deal with these format in your components). I inspired myself from what has been done in the apollo link rest.

image

There is still a lot of stuff to check/do (for example if you have a property of a resource that is a name of a resource, my algorithm will think that it need to callback the API to get it) and I'm currently doing deep traversal (and I'll probably encounter some batch issues).

If you think that it would be useful to implement an apollo-angular-link-rest and that it's a good idea to have the the configuration of the REST outside of queries I would be happy to start something here and have some feedback/help too ! Otherwise I'll keep on my own as I prefer Apollo > (REST + Redux)

@kamilkisiela kamilkisiela added the feature New addition or enhancement to existing solutions label Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New addition or enhancement to existing solutions
Projects
None yet
Development

No branches or pull requests

2 participants