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

Allow practical combination of Query with any schema #2837

Merged
merged 1 commit into from
Nov 8, 2023
Merged

Conversation

ntucker
Copy link
Collaborator

@ntucker ntucker commented Sep 27, 2023

Motivation

Use collections and queries together to make use of their filtering capabilities

export const queryRemainingTodos = new Query(
  TodoResource.getList.schema,
  (entries) => entries && entries.filter((todo) => !todo.completed).length,
);

Solution

Query uses args provided in normalize

args were previously not provided during denormalize, so they were hacked into query by placing them from infer into the input.

Open questions

Without the hack, it's questionable whether QueryEndpoint is still needed. process() could be incorporated into various schemas, and then one schema->endpoint could be used for both index and 'query' use case.

@changeset-bot
Copy link

changeset-bot bot commented Sep 27, 2023

🦋 Changeset detected

Latest commit: de19d0f

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

This PR includes changesets to release 10 packages
Name Type
@data-client/endpoint Minor
@data-client/rest Minor
@data-client/graphql Minor
@data-client/img Minor
example-benchmark Patch
normalizr-github-example Patch
normalizr-redux-example Patch
normalizr-relationships Patch
rdc-website Patch
coinbase-lite 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

@ntucker ntucker force-pushed the query-update branch 5 times, most recently from 2064027 to adbdb71 Compare October 10, 2023 12:28
@ntucker ntucker marked this pull request as ready for review October 10, 2023 12:32
@ntucker ntucker changed the title update query work Allow practical combination of Query with any schema Oct 10, 2023
@codecov
Copy link

codecov bot commented Oct 10, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (005c9de) 98.58% compared to head (de19d0f) 98.58%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2837      +/-   ##
==========================================
- Coverage   98.58%   98.58%   -0.01%     
==========================================
  Files         116      116              
  Lines        1907     1906       -1     
  Branches      277      276       -1     
==========================================
- Hits         1880     1879       -1     
  Misses         14       14              
  Partials       13       13              
Files Coverage Δ
packages/endpoint/src/index.ts 100.00% <ø> (ø)
packages/endpoint/src/queryEndpoint.ts 100.00% <100.00%> (ø)
packages/endpoint/src/schemas/Collection.ts 94.73% <ø> (ø)

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

@ntucker ntucker merged commit 57d87d6 into master Nov 8, 2023
6 checks passed
@ntucker ntucker deleted the query-update branch November 8, 2023 16:18
@github-actions github-actions bot mentioned this pull request Nov 8, 2023
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