add multi spaces filter - #562
Conversation
0420a08 to
c1efd89
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for querying public entities across multiple spaces, introducing a flexible space selection API with three modes: single space, multiple spaces, and all spaces. The implementation includes comprehensive type safety through discriminated unions and updates the GraphQL query generation to handle each mode appropriately.
- Introduces
SpaceSelectionInputtype with three mutually exclusive options:space(single),spaces(array), orspaces: 'all' - Updates GraphQL query builders to conditionally generate filters based on space selection mode
- Exposes the new multi-space API through React hooks (
useEntities,useEntitiesPublicInfinite)
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
packages/hypergraph/src/entity/types.ts |
Defines the SpaceSelectionInput discriminated union type |
packages/hypergraph/src/entity/internal/space-selection.ts |
Implements space selection normalization and validation logic |
packages/hypergraph/test/entity/space-selection.test.ts |
Adds comprehensive tests for space selection normalization |
packages/hypergraph/src/utils/relation-query-helpers.ts |
Updates query builders to accept SpaceSelectionMode and generate appropriate filters |
packages/hypergraph/src/entity/find-many-public.ts |
Integrates space selection into the main query function with dynamic variable definitions |
packages/hypergraph/src/entity/find-one-public.ts |
Updates to pass 'single' mode to relation query builders |
packages/hypergraph/src/entity/search-many-public.ts |
Updates to pass 'single' mode to relation query builders |
packages/hypergraph-react/src/internal/types.ts |
Simplifies type definition by reusing FindManyPublicParams |
packages/hypergraph-react/src/internal/use-entities-public.tsx |
Handles space selection in React query hook |
packages/hypergraph-react/src/hooks/use-entities.tsx |
Adds support for spaces parameter with context fallback |
packages/hypergraph-react/src/hooks/use-entities-public-infinite.ts |
Extends infinite scroll hook to support multi-space queries |
apps/events/src/schema.ts |
Adds Space entity schema for testing |
apps/events/src/routes/podcasts.lazy.tsx |
Demonstrates usage with spaces: 'all' option |
.changeset/shy-bugs-obey.md |
Documents the new feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| backlinksTotalCountsTypeId1: '972d201a-d780-4568-9e01-543f67b26bee', | ||
| }); | ||
|
|
||
| console.log({ data, isLoading, isError }); |
There was a problem hiding this comment.
Debug console.log statement should be removed before merging to production. This log was added as part of testing the new multi-space functionality.
| console.log({ data, isLoading, isError }); |
| console.log('spaces', spaces); | ||
|
|
There was a problem hiding this comment.
Debug console.log statement should be removed before merging to production. This log was added to test the new spaces: 'all' functionality.
| console.log('spaces', spaces); |
| Add support for querying public entities across multiple spaces (including an `all` scope) and expose the new API through the React hooks | ||
|
No newline at end of file |
There was a problem hiding this comment.
Remove trailing whitespace at the end of the line.
| Add support for querying public entities across multiple spaces (including an `all` scope) and expose the new API through the React hooks | |
| Add support for querying public entities across multiple spaces (including an `all` scope) and expose the new API through the React hooks |
| @@ -187,18 +237,26 @@ export const findManyPublic = async <S extends Schema.Schema.AnyNoContext>( | |||
| } | |||
|
|
|||
| // Build the query dynamically with aliases for each relation type ID | |||
There was a problem hiding this comment.
This comment is duplicated on line 242. Consider updating this comment to describe the space selection normalization (e.g., "Normalize space selection from params") and keeping the existing comment on line 242 for the query building.
| // Build the query dynamically with aliases for each relation type ID | |
| // Normalize space selection from params |
No description provided.