reactive / data-client

Async State Management without the Management. REST, GraphQL, SSE, Websockets
https://dataclient.io
Apache License 2.0
1.95k stars 94 forks source link

fix: Collections work with polymorphic schemas and class name mangling #3151

Closed ntucker closed 4 months ago

ntucker commented 4 months ago

Motivation

Solution

Rework Collect.key:

Now relies on its schema to have schemaKey() (which is defined in Polymorphic, so it is inherited by Array, Values, and Union).

new Collection([Todo]).key

'COLLECT:ArraySchema(Todo)' -> '[Todo]'

new Collection(
      new Array(
        {
          users: User,
          groups: Group,
        },
        'type',
      ),
    ).key

FAILED -> '[User;Group]'

changeset-bot[bot] commented 4 months ago

🦋 Changeset detected

Latest commit: 274d856241f208ac50006b36826d848d5d76676e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages | Name | Type | | ------------------------ | ----- | | @data-client/endpoint | Patch | | @data-client/normalizr | Patch | | example-benchmark | Patch | | normalizr-github-example | Patch | | normalizr-redux-example | Patch | | normalizr-relationships | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

codecov[bot] commented 4 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 98.62%. Comparing base (7427519) to head (274d856).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #3151 +/- ## ======================================= Coverage 98.62% 98.62% ======================================= Files 131 131 Lines 2248 2256 +8 Branches 455 458 +3 ======================================= + Hits 2217 2225 +8 Misses 20 20 Partials 11 11 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.