Skip to content

add backlinksTotalCountsTypeId1 - #554

Merged
nikgraf merged 3 commits into
mainfrom
nik/add-backlinksTotalCountsTypeId1
Nov 17, 2025
Merged

add backlinksTotalCountsTypeId1#554
nikgraf merged 3 commits into
mainfrom
nik/add-backlinksTotalCountsTypeId1

Conversation

@nikgraf

@nikgraf nikgraf commented Nov 17, 2025

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a temporary backlinksTotalCountsTypeId1 parameter to entity query functions to enable fetching backlink total counts for a specific type ID. The feature is added to Entity.findManyPublic and the useEntities React hook.

Key changes:

  • Added backlinksTotalCountsTypeId1 optional parameter to all GraphQL queries with conditional inclusion via @include directive
  • Extended return types to include the backlink count in entity results
  • Propagated the parameter through React hooks and TypeScript type definitions

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/hypergraph/src/entity/find-many-public.ts Added backlinksTotalCountsTypeId1 parameter to all 6 GraphQL queries (3 levels × 2 variants), updated types, and added variable handling logic
packages/hypergraph/src/entity/search-many-public.ts Added @ts-expect-error comment due to type mismatch with parseResult function
packages/hypergraph-react/src/internal/use-entities-public.tsx Propagated backlinksTotalCountsTypeId1 parameter to query key and function call
packages/hypergraph-react/src/internal/types.ts Added backlinksTotalCountsTypeId1 to QueryPublicParams type
packages/hypergraph-react/src/hooks/use-entities.tsx Added parameter to hook and type cast for return data
apps/events/src/routes/podcasts.lazy.tsx Example usage showing the new parameter and displaying backlink counts; import order changed
.changeset/kind-peas-sniff.md Documented the change as a patch

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +282 to 283
// @ts-expect-error TODO: fix this
const { data, invalidEntities } = parseResult({ entities: result.search }, type);

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

The parseResult function expects entities with a backlinksTotalCountsTypeId1 field in EntityQueryResult, but SearchQueryResult doesn't include this field. This causes a type error that's being suppressed. To fix this, either add backlinksTotalCountsTypeId1 support to the search queries (similar to find-many-public.ts lines 45-47, 72-74, etc.) or create a separate parse function for search results that doesn't expect this field.

Copilot uses AI. Check for mistakes.
const schemaWithId = Utils.addIdSchemaField(type);
const decode = Schema.decodeUnknownEither(schemaWithId);
const data: Entity.Entity<S>[] = [];
const data: (Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number })[] = [];

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] The return type intersection Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number } is duplicated in multiple places (lines 443 and 46 in use-entities.tsx). Consider defining a reusable type alias like type EntityWithBacklinkCount<S> = Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number } to improve maintainability.

Copilot uses AI. Check for mistakes.
return {
...publicResult,
data: localResult.entities,
data: localResult.entities as (Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number })[],

Copilot AI Nov 17, 2025

Copy link

Choose a reason for hiding this comment

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

The type cast assumes local (private mode) entities will have backlinksTotalCountsTypeId1, but this field is only populated in public mode queries via findManyPublic. Local entities retrieved through useEntitiesPrivate won't have this field, making this cast potentially misleading. The field should be marked as optional and only expected when mode === 'public'.

Copilot uses AI. Check for mistakes.
@nikgraf
nikgraf merged commit d23643d into main Nov 17, 2025
5 checks passed
@nikgraf
nikgraf deleted the nik/add-backlinksTotalCountsTypeId1 branch November 17, 2025 18:27
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.

2 participants