add first filter#314
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a first parameter to limit the number of results in public GraphQL queries.
- Adds
firstto theQueryParamstype and forwards it throughuseQueryanduseQueryPublic. - Updates GraphQL query documents to accept a
$first: Intargument and applies it in the request. - Sets a default
first = 100inuseQueryPublicand demonstrates usage in the playground.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/hypergraph-react/src/use-query.tsx | Added first to params destructuring and forwarding |
| packages/hypergraph-react/src/internal/use-query-public.tsx | Extended queries with $first, default handling, and forwarding |
| packages/hypergraph-react/src/internal/types.ts | Added optional first to QueryPublicParams |
| apps/events/src/components/playground.tsx | Example usage of first parameter |
Comments suppressed due to low confidence (2)
packages/hypergraph-react/src/use-query.tsx:13
- New
firstbehavior isn't covered by existing tests; consider adding unit or integration tests to verify pagination limits in both public and local queries.
first?: number;
packages/hypergraph-react/src/use-query.tsx:150
useQueryLocaldoesn't accept afirstparameter, so local queries cannot be limited; either document this difference or addfirstsupport to local queries for consistency.
const localResult = useQueryLocal(type, { enabled: mode === 'private', filter, include, space });
| mappingEntry?.typeIds, | ||
| relationTypeIdsLevel1, | ||
| relationTypeIdsLevel2, | ||
| // TODO should `first` be in here? |
There was a problem hiding this comment.
The first parameter should be included in the queryKey array to ensure cache entries vary by first value; add first after relationTypeIdsLevel2.
Suggested change
| // TODO should `first` be in here? | |
| first, |
| queryDocument = entitiesQueryDocumentLevel2; | ||
| } | ||
|
|
||
| console.log('first', first); |
There was a problem hiding this comment.
Remove this debug console.log statement to avoid noisy logs in production.
Suggested change
| console.log('first', first); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.