add param offset for Entity.findManyPublic, Entity.searchManyPublic, useEntities - #551
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds pagination support by introducing an offset parameter to entity query functions (Entity.findManyPublic, Entity.searchManyPublic, and useEntities). The implementation enables more granular control over data fetching for improved pagination capabilities.
- Added
offsetparameter with default value of0to core query functions - Updated GraphQL queries across all nesting levels (0, 1, 2) to accept and use the offset parameter
- Integrated offset parameter throughout the React hooks layer, including query cache keys
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hypergraph/src/entity/search-many-public.ts | Added offset parameter to type definition, GraphQL queries (all levels), and function implementation |
| packages/hypergraph/src/entity/find-many-public.ts | Added offset parameter to type definition, GraphQL queries (all levels), and function implementation |
| packages/hypergraph-react/src/internal/use-entities-public.tsx | Added offset to query parameters and query key for cache invalidation |
| packages/hypergraph-react/src/internal/types.ts | Added offset parameter to QueryPublicParams type |
| packages/hypergraph-react/src/hooks/use-entities.tsx | Added offset parameter to UseEntitiesParams and passed through to useEntitiesPublic |
| apps/events/src/routes/podcasts.lazy.tsx | Example usage of new offset parameter with updated space ID and first value |
| apps/events/src/schema.ts | Updated Project and Podcast schema definitions (property and relation ID changes) |
| .changeset/witty-coats-march.md | Changeset documenting the new offset parameter feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| export const useEntitiesPublic = <S extends Schema.Schema.AnyNoContext>(type: S, params?: QueryPublicParams<S>) => { | ||
| const { enabled = true, filter, include, space: spaceFromParams, first = 100 } = params ?? {}; | ||
| const { enabled = true, filter, include, space: spaceFromParams, first = 100, offset } = params ?? {}; |
There was a problem hiding this comment.
[nitpick] The offset parameter should have a default value of 0 to be consistent with the implementation in findManyPublic and searchManyPublic functions. Without a default, if offset is undefined, it will be passed as undefined to Entity.findManyPublic, though the function itself has a default value that will handle it. For consistency and clarity, consider adding the default here:
const { enabled = true, filter, include, space: spaceFromParams, first = 100, offset = 0 } = params ?? {};| const { enabled = true, filter, include, space: spaceFromParams, first = 100, offset } = params ?? {}; | |
| const { enabled = true, filter, include, space: spaceFromParams, first = 100, offset = 0 } = params ?? {}; |
| add param `offset` for Entity.findManyPublic, Entity.searchManyPublic, useEntities | ||
|
No newline at end of file |
There was a problem hiding this comment.
[nitpick] This line contains trailing whitespace. Consider removing it to maintain code cleanliness.
| add param `offset` for Entity.findManyPublic, Entity.searchManyPublic, useEntities | |
| add param `offset` for Entity.findManyPublic, Entity.searchManyPublic, useEntities |
No description provided.