Skip to content

Conversation

@mpugach
Copy link

@mpugach mpugach commented Dec 23, 2019

In some cases, there are too many relations and we need to paginate them.

Also, we would like to utilize nested routes (chats/1/messages instead of messages?filter[chat]=1).

Dunno is it related to #103

Can we just expose the relationship links? Because it feels natural to receive them from the backend.

Then we could do something like this:

export class DatastoreService extends JsonApiDatastore {
  constructor(http: HttpClient) {
    super(http);

    this.headers = new HttpHeaders({
      accept: 'application/vnd.api+json',
      'content-type': 'application/vnd.api+json',
      'x-auth-token': getSomeToken(),
    });
  }

  getRelationPageOrSomthingBetterNamed(
    model: ModelType<JsonApiModel>,
    url: string
  ) {
    return this.findAll(
        model,
        {},
        this.getOptions().headers,
        url
      );
  }
}

const messageObservable = this.datastore.getRelationPageOrSomthingBetterNamed(
  Message,
  chat.relationshipLinks.messages.links.next // http://localhost:7000/api/v1/chats/1/messages?page[number]=2
);

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 91.312% when pulling 198de23 on mpugach:expose_relationship_links into 378c4dd on ghidoz:master.

@mpugach mpugach closed this Jul 23, 2020
@mpugach
Copy link
Author

mpugach commented Jul 23, 2020

closed due to lack of response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants