Skip to content

API request result.entities contains records in a different order than they were returned from the server. #123

@omanizer

Description

@omanizer

Describe the bug

This is more of a question but something that might be worth addressing. I have an API endpoint that returns a list of conversations. If I pass in a query string parameter "include_archived" it returns a full list of conversations (including those that have been archived). This endpoint always returns the conversations in order of time descending. It seems that the order of records in the 'entities' property of a request result does not always match the order of records returned from the server. This mainly happens when the server returns some new records and some that already exist in the store.

Steps to reproduce the bug

  1. Define models
  2. Create data
  3. Retrieve data from API that contains a few records (for example primary keys: 1, 4, and 5) result = Conversation.api().get('/conversations')
  4. Retrieve data from API that contains records from above as well as some different ones (so for example primary keys: 1, 2, 3, 4, and 5) result = Conversation.api().get('/conversations?include_archived=true')
  5. Observe that result.entities.conversations is not in the order 1, 2, 3, 4, 5.
  6. Also observe that result.response.data (returned from server) does have the order 1, 2, 3, 4, 5.

Expected behavior

It would be nice if result.entities could contain the records in the same order that they were returned from the server.

I can manually sort these after the fact but it would be more efficient if sorting could just be assumed since this is being used on an infinite scroll and sometimes users have hundreds of conversations being loaded into a single view.

Versions

  • Vuex ORM Axios: 0.9.2
  • Vuex ORM: 0.36.3

Thanks so much for your consideration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions