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
6 changes: 6 additions & 0 deletions .changeset/empty-rivers-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphprotocol/hypergraph-react": patch
---

Update variable types of usePublishToPublicSpace function to accept and instance of an Entity and not the Entity type

12 changes: 7 additions & 5 deletions packages/hypergraph-react/src/hooks/usePublishToSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@ import { publishOps } from '../publish-ops.js';
import type { OmitStrict } from '../types.js';

type Variables<S extends Entity.AnyNoContext> = {
entity: S;
entity: Entity.Entity<S>;
spaceId: string;
};

type UsePublishToSpaceOptions = OmitStrict<
UseMutationOptions<Awaited<ReturnType<typeof publishOps>>, Error, Variables<Entity.AnyNoContext>, unknown>,
type UsePublishToSpaceOptions<S extends Entity.AnyNoContext> = OmitStrict<
UseMutationOptions<Awaited<ReturnType<typeof publishOps>>, Error, Variables<S>, unknown>,
'mutationFn' | 'mutationKey'
>;

export function usePublishToPublicSpace(options: UsePublishToSpaceOptions = {}) {
export function usePublishToPublicSpace<const S extends Entity.AnyNoContext>(
options: UsePublishToSpaceOptions<S> = {},
) {
const { getSmartSessionClient } = useHypergraphApp();

return useMutation({
...options,
mutationFn: async ({ entity, spaceId }) => {
const { ops } = await preparePublish({
const { ops } = await preparePublish<S>({
entity,
publicSpace: spaceId,
});
Expand Down
Loading