Skip to content

Commit d7b4fe0

Browse files
authored
fix(usePublishToPublicSpace): update entity type def to be instance of type (#448)
1 parent e97a711 commit d7b4fe0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

.changeset/empty-rivers-talk.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@graphprotocol/hypergraph-react": patch
3+
---
4+
5+
Update variable types of usePublishToPublicSpace function to accept and instance of an Entity and not the Entity type
6+

packages/hypergraph-react/src/hooks/usePublishToSpace.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@ import { publishOps } from '../publish-ops.js';
66
import type { OmitStrict } from '../types.js';
77

88
type Variables<S extends Entity.AnyNoContext> = {
9-
entity: S;
9+
entity: Entity.Entity<S>;
1010
spaceId: string;
1111
};
1212

13-
type UsePublishToSpaceOptions = OmitStrict<
14-
UseMutationOptions<Awaited<ReturnType<typeof publishOps>>, Error, Variables<Entity.AnyNoContext>, unknown>,
13+
type UsePublishToSpaceOptions<S extends Entity.AnyNoContext> = OmitStrict<
14+
UseMutationOptions<Awaited<ReturnType<typeof publishOps>>, Error, Variables<S>, unknown>,
1515
'mutationFn' | 'mutationKey'
1616
>;
1717

18-
export function usePublishToPublicSpace(options: UsePublishToSpaceOptions = {}) {
18+
export function usePublishToPublicSpace<const S extends Entity.AnyNoContext>(
19+
options: UsePublishToSpaceOptions<S> = {},
20+
) {
1921
const { getSmartSessionClient } = useHypergraphApp();
2022

2123
return useMutation({
2224
...options,
2325
mutationFn: async ({ entity, spaceId }) => {
24-
const { ops } = await preparePublish({
26+
const { ops } = await preparePublish<S>({
2527
entity,
2628
publicSpace: spaceId,
2729
});

0 commit comments

Comments
 (0)