Skip to content

Commit 956aaa4

Browse files
authored
remove backlinksTotalCountsTypeId1 (#572)
1 parent e4a7f22 commit 956aaa4

6 files changed

Lines changed: 10 additions & 40 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"@graphprotocol/hypergraph": patch
3+
"@graphprotocol/hypergraph-react": patch
4+
---
5+
6+
Removed the temporary `backlinksTotalCountsTypeId1` option and response field from `Entity.findManyPublic` and the React `useEntities` helpers.
7+

apps/events/src/routes/podcasts.lazy.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ function RouteComponent() {
7979
episodesTotalCount: true,
8080
},
8181
orderBy: { property: 'dateFounded', direction: 'asc' },
82-
backlinksTotalCountsTypeId1: '972d201a-d780-4568-9e01-543f67b26bee',
8382
});
8483

8584
console.log({ data, isLoading, isError });
@@ -117,7 +116,7 @@ function RouteComponent() {
117116
{data?.map((podcast) => (
118117
<div key={podcast.id}>
119118
<h2>
120-
{podcast.backlinksTotalCountsTypeId1} - {podcast.dateFounded.toISOString()} {podcast.name} - {podcast.id}
119+
{podcast.dateFounded.toISOString()} {podcast.name} - {podcast.id}
121120
</h2>
122121
{podcast.listenOn.map((listenOn) => (
123122
<div key={listenOn._relation.id}>

packages/hypergraph-react/src/hooks/use-entities.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ type UseEntitiesParams<
2727
direction: 'asc' | 'desc';
2828
}
2929
| undefined;
30-
backlinksTotalCountsTypeId1?: string | undefined;
3130
includeSpaceIds?: IncludeSpaceIds;
3231
logInvalidResults?: boolean;
3332
};
@@ -41,7 +40,7 @@ type UseEntitiesPrivateResult<S extends Schema.Schema.AnyNoContext> = Omit<
4140
UseEntitiesPublicResult<S, false>,
4241
'data'
4342
> & {
44-
data: (Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number })[];
43+
data: Entity.Entity<S>[];
4544
deleted: Entity.Entity<S>[];
4645
};
4746

@@ -65,7 +64,6 @@ export function useEntities<
6564
first,
6665
offset,
6766
orderBy,
68-
backlinksTotalCountsTypeId1,
6967
includeSpaceIds,
7068
logInvalidResults: logInvalidResultsParam,
7169
} = params;
@@ -81,7 +79,6 @@ export function useEntities<
8179
first,
8280
offset,
8381
orderBy,
84-
backlinksTotalCountsTypeId1,
8582
...(includeSpaceIds !== undefined ? { includeSpaceIds } : {}),
8683
...publicSpaceParams,
8784
logInvalidResults,
@@ -97,7 +94,7 @@ export function useEntities<
9794

9895
return {
9996
...publicResult,
100-
data: localResult.entities as (Entity.Entity<S> & { backlinksTotalCountsTypeId1?: number })[],
97+
data: localResult.entities,
10198
deleted: localResult.deletedEntities,
10299
} as UseEntitiesResult<S, IncludeSpaceIds, Mode>;
103100
}

packages/hypergraph-react/src/internal/use-entities-public.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ export const useEntitiesPublic: UseEntitiesPublicFn = (type, params) => {
3535
first = 100,
3636
offset,
3737
orderBy,
38-
backlinksTotalCountsTypeId1,
3938
includeSpaceIds: includeSpaceIdsParam,
4039
logInvalidResults = true,
4140
} = params ?? {};
@@ -57,7 +56,6 @@ export const useEntitiesPublic: UseEntitiesPublicFn = (type, params) => {
5756
first,
5857
offset,
5958
orderBy,
60-
backlinksTotalCountsTypeId1,
6159
includeSpaceIds,
6260
],
6361
queryFn: async () => {
@@ -68,7 +66,6 @@ export const useEntitiesPublic: UseEntitiesPublicFn = (type, params) => {
6866
first,
6967
offset,
7068
orderBy,
71-
backlinksTotalCountsTypeId1,
7269
...(includeSpaceIdsParam !== undefined ? { includeSpaceIds: includeSpaceIdsParam } : {}),
7370
logInvalidResults,
7471
});

packages/hypergraph/src/entity/find-many-public.ts

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export type FindManyPublicParams<
2929
direction: 'asc' | 'desc';
3030
}
3131
| undefined;
32-
backlinksTotalCountsTypeId1?: string | undefined;
3332
includeSpaceIds?: IncludeSpaceIds;
3433
logInvalidResults?: boolean | undefined;
3534
};
@@ -56,8 +55,6 @@ const buildEntitiesQuery = (
5655
'$first: Int',
5756
'$filter: EntityFilter!',
5857
'$offset: Int',
59-
'$backlinksTotalCountsTypeId1: UUID',
60-
'$backlinksTotalCountsTypeId1Present: Boolean!',
6158
]
6259
.filter(Boolean)
6360
.join(', ');
@@ -75,12 +72,6 @@ const buildEntitiesQuery = (
7572
: spaceSelection.mode === 'many'
7673
? '(filter: { spaceId: { in: $spaceIds } })'
7774
: '';
78-
const backlinksSpaceFilter =
79-
spaceSelection.mode === 'single'
80-
? 'spaceId: {is: $spaceId}, '
81-
: spaceSelection.mode === 'many'
82-
? 'spaceId: {in: $spaceIds}, '
83-
: '';
8475

8576
return `
8677
query ${queryName}(${variableDefinitions}) {
@@ -102,9 +93,6 @@ query ${queryName}(${variableDefinitions}) {
10293
time
10394
point
10495
}
105-
backlinksTotalCountsTypeId1: backlinks(filter: { ${backlinksSpaceFilter}fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
106-
totalCount
107-
}
10896
${level1Relations}
10997
}
11098
}`;
@@ -132,9 +120,6 @@ export type EntityQueryResult = {
132120
name: string;
133121
spaceIds: readonly (string | null)[] | null;
134122
valuesList: ValuesList;
135-
backlinksTotalCountsTypeId1: {
136-
totalCount: number;
137-
} | null;
138123
} & {
139124
// For aliased relations_* fields - provides proper typing with totalCount
140125
[K: `relations_${string}`]: RelationsListWithNodes | undefined;
@@ -148,7 +133,6 @@ type ParsedEntity<
148133
IncludeSpaceIds extends boolean | undefined,
149134
> = Entity.WithSpaceIds<Entity.Entity<S>, IncludeSpaceIds> & {
150135
__schema: S;
151-
backlinksTotalCountsTypeId1?: number;
152136
};
153137

154138
export type FindManyParseResult<S extends Schema.Schema.AnyNoContext, IncludeSpaceIds extends boolean | undefined> = {
@@ -219,7 +203,6 @@ export const parseResult = <S extends Schema.Schema.AnyNoContext, IncludeSpaceId
219203
const baseEntity = {
220204
...decodeResult.right,
221205
__schema: type,
222-
backlinksTotalCountsTypeId1: queryEntity.backlinksTotalCountsTypeId1?.totalCount,
223206
};
224207
const entityWithSpaceIds = (
225208
includeSpaceIds
@@ -259,7 +242,6 @@ export const findManyPublic = async <
259242
first = 100,
260243
offset = 0,
261244
orderBy,
262-
backlinksTotalCountsTypeId1,
263245
includeSpaceIds: includeSpaceIdsParam,
264246
logInvalidResults = true,
265247
} = params ?? {};
@@ -325,13 +307,6 @@ export const findManyPublic = async <
325307
queryVariables.sortDirection = sortDirection;
326308
}
327309

328-
if (backlinksTotalCountsTypeId1) {
329-
queryVariables.backlinksTotalCountsTypeId1 = backlinksTotalCountsTypeId1;
330-
queryVariables.backlinksTotalCountsTypeId1Present = true;
331-
} else {
332-
queryVariables.backlinksTotalCountsTypeId1Present = false;
333-
}
334-
335310
const result = await request<EntityQueryResult>(`${Graph.TESTNET_API_ORIGIN}/graphql`, queryDocument, queryVariables);
336311

337312
const { data, invalidEntities, invalidRelationEntities } = parseResult<S, IncludeSpaceIds>(

packages/hypergraph/test/entity/find-many-public.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,12 @@ describe('findManyPublic parseResult', () => {
5757
name: 'Parent valid',
5858
valuesList: [buildValueEntry(TITLE_PROPERTY_ID, { string: 'Parent valid' })],
5959
spaceIds: [],
60-
backlinksTotalCountsTypeId1: null,
6160
},
6261
{
6362
id: 'parent-invalid',
6463
name: 'Parent invalid',
6564
valuesList: [],
6665
spaceIds: [],
67-
backlinksTotalCountsTypeId1: null,
6866
},
6967
],
7068
};
@@ -88,7 +86,6 @@ describe('findManyPublic parseResult', () => {
8886
name: 'Parent with invalid child',
8987
valuesList: [buildValueEntry(TITLE_PROPERTY_ID, { string: 'Parent with invalid child' })],
9088
spaceIds: [],
91-
backlinksTotalCountsTypeId1: null,
9289
[relationAlias]: {
9390
nodes: [
9491
{
@@ -107,7 +104,6 @@ describe('findManyPublic parseResult', () => {
107104
],
108105
};
109106

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

113109
expect(result.data).toHaveLength(1);
@@ -128,7 +124,6 @@ describe('findManyPublic parseResult', () => {
128124
name: 'Parent with spaces',
129125
valuesList: [buildValueEntry(TITLE_PROPERTY_ID, { string: 'Parent with spaces' })],
130126
spaceIds: ['space-1', null, 'space-2'],
131-
backlinksTotalCountsTypeId1: null,
132127
},
133128
],
134129
};

0 commit comments

Comments
 (0)