the-guild-org / the-guild-org/apollo-angular

Apollo Angular Link REST

Open
#1,184 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.5k
Forks
309
Avg merge
1h 45m
Merged PRs (30d)
3

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the apollo-angular-link-http implementation and the apollo-link-rest project referenced in the issue. Evaluate the proposed endpoints configuration, response mapper, Angular HttpClient compatibility, traversal behavior, and possible batching issues; done requires an agreed scope before implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, graphql, typescript
Domain
api, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.