Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .changeset/remove-backlinks-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@graphprotocol/hypergraph": patch
"@graphprotocol/hypergraph-react": patch
---

Removed the temporary `backlinksTotalCountsTypeId1` option and response field from `Entity.findManyPublic` and the React `useEntities` helpers.

3 changes: 1 addition & 2 deletions apps/events/src/routes/podcasts.lazy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function RouteComponent() {
episodesTotalCount: true,
},
orderBy: { property: 'dateFounded', direction: 'asc' },
backlinksTotalCountsTypeId1: '972d201a-d780-4568-9e01-543f67b26bee',
});

console.log({ data, isLoading, isError });
Expand Down Expand Up @@ -117,7 +116,7 @@ function RouteComponent() {
{data?.map((podcast) => (
<div key={podcast.id}>
<h2>
{podcast.backlinksTotalCountsTypeId1} - {podcast.dateFounded.toISOString()} {podcast.name} - {podcast.id}
{podcast.dateFounded.toISOString()} {podcast.name} - {podcast.id}
</h2>
{podcast.listenOn.map((listenOn) => (
<div key={listenOn._relation.id}>
Expand Down
7 changes: 2 additions & 5 deletions packages/hypergraph-react/src/hooks/use-entities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ type UseEntitiesParams<
direction: 'asc' | 'desc';
}
| undefined;
backlinksTotalCountsTypeId1?: string | undefined;
includeSpaceIds?: IncludeSpaceIds;
logInvalidResults?: boolean;
};
Expand All @@ -41,7 +40,7 @@ type UseEntitiesPrivateResult<S extends Schema.Schema.AnyNoContext> = Omit<
UseEntitiesPublicResult<S, false>,
'data'
> & {
data: (Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number })[];
data: Entity.Entity<S>[];
deleted: Entity.Entity<S>[];
};

Expand All @@ -65,7 +64,6 @@ export function useEntities<
first,
offset,
orderBy,
backlinksTotalCountsTypeId1,
includeSpaceIds,
logInvalidResults: logInvalidResultsParam,
} = params;
Expand All @@ -81,7 +79,6 @@ export function useEntities<
first,
offset,
orderBy,
backlinksTotalCountsTypeId1,
...(includeSpaceIds !== undefined ? { includeSpaceIds } : {}),
...publicSpaceParams,
logInvalidResults,
Expand All @@ -97,7 +94,7 @@ export function useEntities<

return {
...publicResult,
data: localResult.entities as (Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number })[],
data: localResult.entities,
deleted: localResult.deletedEntities,
} as UseEntitiesResult<S, IncludeSpaceIds, Mode>;
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export const useEntitiesPublic: UseEntitiesPublicFn = (type, params) => {
first = 100,
offset,
orderBy,
backlinksTotalCountsTypeId1,
includeSpaceIds: includeSpaceIdsParam,
logInvalidResults = true,
} = params ?? {};
Expand All @@ -57,7 +56,6 @@ export const useEntitiesPublic: UseEntitiesPublicFn = (type, params) => {
first,
offset,
orderBy,
backlinksTotalCountsTypeId1,
includeSpaceIds,
],
queryFn: async () => {
Expand All @@ -68,7 +66,6 @@ export const useEntitiesPublic: UseEntitiesPublicFn = (type, params) => {
first,
offset,
orderBy,
backlinksTotalCountsTypeId1,
...(includeSpaceIdsParam !== undefined ? { includeSpaceIds: includeSpaceIdsParam } : {}),
logInvalidResults,
});
Expand Down
25 changes: 0 additions & 25 deletions packages/hypergraph/src/entity/find-many-public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export type FindManyPublicParams<
direction: 'asc' | 'desc';
}
| undefined;
backlinksTotalCountsTypeId1?: string | undefined;
includeSpaceIds?: IncludeSpaceIds;
logInvalidResults?: boolean | undefined;
};
Expand All @@ -56,8 +55,6 @@ const buildEntitiesQuery = (
'$first: Int',
'$filter: EntityFilter!',
'$offset: Int',
'$backlinksTotalCountsTypeId1: UUID',
'$backlinksTotalCountsTypeId1Present: Boolean!',
]
.filter(Boolean)
.join(', ');
Expand All @@ -75,12 +72,6 @@ const buildEntitiesQuery = (
: spaceSelection.mode === 'many'
? '(filter: { spaceId: { in: $spaceIds } })'
: '';
const backlinksSpaceFilter =
spaceSelection.mode === 'single'
? 'spaceId: {is: $spaceId}, '
: spaceSelection.mode === 'many'
? 'spaceId: {in: $spaceIds}, '
: '';

return `
query ${queryName}(${variableDefinitions}) {
Expand All @@ -102,9 +93,6 @@ query ${queryName}(${variableDefinitions}) {
time
point
}
backlinksTotalCountsTypeId1: backlinks(filter: { ${backlinksSpaceFilter}fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
totalCount
}
${level1Relations}
}
}`;
Expand Down Expand Up @@ -132,9 +120,6 @@ export type EntityQueryResult = {
name: string;
spaceIds: readonly (string | null)[] | null;
valuesList: ValuesList;
backlinksTotalCountsTypeId1: {
totalCount: number;
} | null;
} & {
// For aliased relations_* fields - provides proper typing with totalCount
[K: `relations_${string}`]: RelationsListWithNodes | undefined;
Expand All @@ -148,7 +133,6 @@ type ParsedEntity<
IncludeSpaceIds extends boolean | undefined,
> = Entity.WithSpaceIds<Entity.Entity<S>, IncludeSpaceIds> & {
__schema: S;
backlinksTotalCountsTypeId1?: number;
};

export type FindManyParseResult<S extends Schema.Schema.AnyNoContext, IncludeSpaceIds extends boolean | undefined> = {
Expand Down Expand Up @@ -219,7 +203,6 @@ export const parseResult = <S extends Schema.Schema.AnyNoContext, IncludeSpaceId
const baseEntity = {
...decodeResult.right,
__schema: type,
backlinksTotalCountsTypeId1: queryEntity.backlinksTotalCountsTypeId1?.totalCount,
};
const entityWithSpaceIds = (
includeSpaceIds
Expand Down Expand Up @@ -259,7 +242,6 @@ export const findManyPublic = async <
first = 100,
offset = 0,
orderBy,
backlinksTotalCountsTypeId1,
includeSpaceIds: includeSpaceIdsParam,
logInvalidResults = true,
} = params ?? {};
Expand Down Expand Up @@ -325,13 +307,6 @@ export const findManyPublic = async <
queryVariables.sortDirection = sortDirection;
}

if (backlinksTotalCountsTypeId1) {
queryVariables.backlinksTotalCountsTypeId1 = backlinksTotalCountsTypeId1;
queryVariables.backlinksTotalCountsTypeId1Present = true;
} else {
queryVariables.backlinksTotalCountsTypeId1Present = false;
}

const result = await request<EntityQueryResult>(`${Graph.TESTNET_API_ORIGIN}/graphql`, queryDocument, queryVariables);

const { data, invalidEntities, invalidRelationEntities } = parseResult<S, IncludeSpaceIds>(
Expand Down
5 changes: 0 additions & 5 deletions packages/hypergraph/test/entity/find-many-public.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,12 @@ describe('findManyPublic parseResult', () => {
name: 'Parent valid',
valuesList: [buildValueEntry(TITLE_PROPERTY_ID, { string: 'Parent valid' })],
spaceIds: [],
backlinksTotalCountsTypeId1: null,
},
{
id: 'parent-invalid',
name: 'Parent invalid',
valuesList: [],
spaceIds: [],
backlinksTotalCountsTypeId1: null,
},
],
};
Expand All @@ -88,7 +86,6 @@ describe('findManyPublic parseResult', () => {
name: 'Parent with invalid child',
valuesList: [buildValueEntry(TITLE_PROPERTY_ID, { string: 'Parent with invalid child' })],
spaceIds: [],
backlinksTotalCountsTypeId1: null,
[relationAlias]: {
nodes: [
{
Expand All @@ -107,7 +104,6 @@ describe('findManyPublic parseResult', () => {
],
};

// @ts-expect-error
const result = parseResult(queryData, Parent, relationInfo);

expect(result.data).toHaveLength(1);
Expand All @@ -128,7 +124,6 @@ describe('findManyPublic parseResult', () => {
name: 'Parent with spaces',
valuesList: [buildValueEntry(TITLE_PROPERTY_ID, { string: 'Parent with spaces' })],
spaceIds: ['space-1', null, 'space-2'],
backlinksTotalCountsTypeId1: null,
},
],
};
Expand Down
Loading