Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance: Entity.pk() default provided that uses id #3188

Merged
merged 4 commits into from
Aug 14, 2024
Merged

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Aug 13, 2024

Motivation

More terse common case.

Solution

Outcome

  • Entity with no pk() override will use the id member
  • In DEV mode normalize with missing id will alert user they need to override Entity.pk()

Changes

  • Remove Entity's special abstract pk() type (schema.Entity mixin already defaults to this.id)
  • Add special error message in EntitySchema.normalize() when default implementation is used but id is not present

Copy link

changeset-bot bot commented Aug 13, 2024

🦋 Changeset detected

Latest commit: 7cd6fb1

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

This PR includes changesets to release 11 packages
Name Type
@data-client/endpoint Patch
@data-client/graphql Patch
@data-client/rest Patch
@data-client/normalizr Patch
@data-client/react Patch
@data-client/core Patch
@data-client/test 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

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 7cd6fb1 Previous: 1e8a95d Ratio
normalizeLong 515 ops/sec (±0.32%) 525 ops/sec (±0.27%) 1.02
infer All 9382 ops/sec (±0.67%) 9498 ops/sec (±0.34%) 1.01
denormalizeLong 336 ops/sec (±1.00%) 344 ops/sec (±2.16%) 1.02
denormalizeLong donotcache 894 ops/sec (±0.26%) 877 ops/sec (±0.59%) 0.98
denormalizeShort donotcache 500x 1371 ops/sec (±0.24%) 1389 ops/sec (±0.20%) 1.01
denormalizeShort 500x 969 ops/sec (±0.25%) 983 ops/sec (±0.27%) 1.01
denormalizeShort 500x withCache 4974 ops/sec (±0.68%) 5072 ops/sec (±0.69%) 1.02
denormalizeLong with mixin Entity 302 ops/sec (±0.38%) 302 ops/sec (±0.29%) 1
denormalizeLong withCache 6855 ops/sec (±0.23%) 6245 ops/sec (±0.15%) 0.91
denormalizeLong All withCache 6775 ops/sec (±0.15%) 6559 ops/sec (±0.16%) 0.97
denormalizeLong Query-sorted withCache 6485 ops/sec (±0.85%) 6195 ops/sec (±0.59%) 0.96
denormalizeLongAndShort withEntityCacheOnly 1515 ops/sec (±0.41%) 1516 ops/sec (±0.44%) 1.00
getResponse 6057 ops/sec (±1.39%) 5931 ops/sec (±1.47%) 0.98
getResponse (null) 5426291 ops/sec (±1.20%) 5519711 ops/sec (±0.85%) 1.02
getResponse (clear cache) 293 ops/sec (±1.26%) 295 ops/sec (±0.31%) 1.01
getSmallResponse 2619 ops/sec (±0.33%) 2623 ops/sec (±0.31%) 1.00
getSmallInferredResponse 2083 ops/sec (±0.22%) 2038 ops/sec (±0.34%) 0.98
getResponse Query-sorted 6833 ops/sec (±0.54%) 5425 ops/sec (±0.47%) 0.79
getResponse Collection 6528 ops/sec (±0.79%) 5985 ops/sec (±0.90%) 0.92
get Collection 5275 ops/sec (±1.43%) 4957 ops/sec (±1.56%) 0.94
setLong 513 ops/sec (±0.48%) 516 ops/sec (±0.29%) 1.01
setLongWithMerge 204 ops/sec (±0.26%) 197 ops/sec (±1.90%) 0.97
setLongWithSimpleMerge 213 ops/sec (±0.35%) 214 ops/sec (±0.29%) 1.00
setSmallResponse 500x 906 ops/sec (±0.28%) 890 ops/sec (±0.51%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

codecov bot commented Aug 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.76%. Comparing base (3ce0bbf) to head (b9ad7e9).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3188      +/-   ##
==========================================
- Coverage   98.76%   98.76%   -0.01%     
==========================================
  Files         132      132              
  Lines        2271     2269       -2     
  Branches      467      467              
==========================================
- Hits         2243     2241       -2     
+ Misses         17       16       -1     
- Partials       11       12       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ntucker ntucker merged commit cde7121 into master Aug 14, 2024
26 checks passed
@ntucker ntucker deleted the default-pk branch August 14, 2024 13:45
@github-actions github-actions bot mentioned this pull request Aug 14, 2024
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.

1 participant