Skip to content

Commit f7319e0

Browse files
authored
remove injected __schema from findManyPublic and useEntities (public) entries (#574)
1 parent 38f70f3 commit f7319e0

2 files changed

Lines changed: 11 additions & 15 deletions

File tree

.changeset/fine-points-stop.md

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+
remove injected __schema from findManyPublic and useEntities in public mode entries
7+

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

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,8 @@ export type EntityQueryResult = {
128128

129129
type GraphSortDirection = 'ASC' | 'DESC';
130130

131-
type ParsedEntity<
132-
S extends Schema.Schema.AnyNoContext,
133-
IncludeSpaceIds extends boolean | undefined,
134-
> = Entity.WithSpaceIds<Entity.Entity<S>, IncludeSpaceIds> & {
135-
__schema: S;
136-
};
137-
138131
export type FindManyParseResult<S extends Schema.Schema.AnyNoContext, IncludeSpaceIds extends boolean | undefined> = {
139-
data: ParsedEntity<S, IncludeSpaceIds>[];
132+
data: Entity.WithSpaceIds<Entity.Entity<S>, IncludeSpaceIds>[];
140133
invalidEntities: InvalidEntity[];
141134
invalidRelationEntities: InvalidRelationEntity[];
142135
};
@@ -150,7 +143,7 @@ export const parseResult = <S extends Schema.Schema.AnyNoContext, IncludeSpaceId
150143
const includeSpaceIds = options?.includeSpaceIds ?? false;
151144
const schemaWithId = Utils.addIdSchemaField(type);
152145
const decode = Schema.decodeUnknownEither(schemaWithId);
153-
const data: ParsedEntity<S, IncludeSpaceIds>[] = [];
146+
const data: Entity.WithSpaceIds<Entity.Entity<S>, IncludeSpaceIds>[] = [];
154147
const invalidEntities: InvalidEntity[] = [];
155148
const invalidRelationEntities: InvalidRelationEntity[] = [];
156149

@@ -200,19 +193,15 @@ export const parseResult = <S extends Schema.Schema.AnyNoContext, IncludeSpaceId
200193
});
201194

202195
if (Either.isRight(decodeResult)) {
203-
const baseEntity = {
204-
...decodeResult.right,
205-
__schema: type,
206-
};
196+
const baseEntity = decodeResult.right;
207197
const entityWithSpaceIds = (
208198
includeSpaceIds
209199
? {
210200
...baseEntity,
211201
spaceIds: normalizeSpaceIds(queryEntity.spaceIds),
212202
}
213203
: baseEntity
214-
) as ParsedEntity<S, IncludeSpaceIds>;
215-
// injecting the schema to the entity to be able to access it in the preparePublish function
204+
) as Entity.WithSpaceIds<Entity.Entity<S>, IncludeSpaceIds>;
216205
data.push(entityWithSpaceIds);
217206
} else {
218207
const invalidRawEntity = includeSpaceIds

0 commit comments

Comments
 (0)