You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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)
The text was updated successfully, but these errors were encountered:
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.
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)
The text was updated successfully, but these errors were encountered: