Skip to content

Commit 14dbba8

Browse files
authored
switch to the new api (#309)
1 parent a96c367 commit 14dbba8

File tree

14 files changed

+102
-131
lines changed

14 files changed

+102
-131
lines changed

apps/connect/.env.development

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="http://localhost:3030"
22
VITE_HYPERGRAPH_CHAIN="geo-testnet"
3-
VITE_HYPERGRAPH_API_URL="https://hypergraph-v2-testnet.up.railway.app/graphql"
3+
VITE_HYPERGRAPH_API_URL="https://v2-postgraphile.up.railway.app/graphql"
44
VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz"
55
VITE_PRIVY_APP_ID="cmbhnmo1x000bla0mxudtd8z9"
66
VITE_PRIVY_PROVIDERS="development"

apps/connect/.env.production

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="https://syncserver.hypergraph.thegraph.com"
22
VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="https://hypergraph.fly.dev"
33
VITE_HYPERGRAPH_CHAIN="geo-testnet"
4-
VITE_HYPERGRAPH_API_URL="https://hypergraph-v2-testnet.up.railway.app/graphql"
4+
VITE_HYPERGRAPH_API_URL="https://v2-postgraphile.up.railway.app/graphql"
55
VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz"
66
VITE_PRIVY_APP_ID="cmcccikza007bjy0niawgutl0"
77
VITE_PRIVY_PROVIDERS="production"

apps/connect/src/hooks/use-public-spaces.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ import { gql, request } from 'graphql-request';
44

55
const publicSpacesQueryDocument = gql`
66
query Spaces($accountAddress: String!) {
7-
spaces(filter: { member: { is: $accountAddress } }) {
7+
spaces(filter: {members: {some: {address: {is: $accountAddress}}}}) {
88
id
99
type
1010
mainVotingAddress
1111
personalAddress
12-
entity {
12+
page {
1313
name
1414
}
1515
}
@@ -21,7 +21,7 @@ type SpaceQueryResult = {
2121
type: string;
2222
mainVotingAddress: string;
2323
personalAddress: string;
24-
entity: {
24+
page: {
2525
name: string;
2626
};
2727
};
@@ -50,7 +50,7 @@ export const usePublicSpaces = (url: string): UseQueryResult<PublicSpaceData[],
5050
return result?.spaces
5151
? result.spaces.map((space: SpaceQueryResult) => ({
5252
id: space.id,
53-
name: space.entity.name,
53+
name: space.page.name,
5454
type: space.type,
5555
mainVotingAddress: space.mainVotingAddress,
5656
personalAddress: space.personalAddress,

apps/events/src/components/create-events.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ const createEvents = async ({
4747
});
4848
ops.push(...createCompanyTypeOps);
4949

50-
const { ops: createEventTypeOps } = Graph.createEntity({
50+
console.log('companyTypeId', companyTypeId);
51+
52+
const { ops: createEventTypeOps, id: eventTypeId } = Graph.createEntity({
5153
name: 'My Test Event',
5254
types: mapping.Event.typeIds,
5355
relations: {
@@ -56,13 +58,15 @@ const createEvents = async ({
5658
});
5759
ops.push(...createEventTypeOps);
5860

61+
console.log('eventTypeId', eventTypeId);
62+
5963
const result = await publishOps({
6064
ops,
6165
walletClient: smartSessionClient,
6266
space,
6367
name: 'Create Job Offers, Companies and Events',
6468
});
65-
console.log('result', result);
69+
console.log('result', result, ops);
6670
alert('Events created');
6771
} catch (error) {
6872
console.error('error', error);

apps/events/src/components/playground.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const Playground = () => {
4747
const { success, cid, txResult } = await createEntity(
4848
{
4949
name: 'Test Event 42 by Nik',
50-
sponsors: ['347676a1-7cef-47dc-b6a7-c94fc6237dcd'],
50+
sponsors: [],
5151
},
5252
{ walletClient },
5353
);

apps/events/src/mapping.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,28 @@ import type { Mapping } from '@graphprotocol/hypergraph';
33

44
export const mapping: Mapping = {
55
Event: {
6-
typeIds: [Id.Id('407d9e8a-c703-4fb4-830d-98c758c8564e')],
6+
typeIds: [Id.Id('7f9562d4-034d-4385-bf5c-f02cdebba47a')],
77
properties: {
88
name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'),
99
},
1010
relations: {
11-
sponsors: Id.Id('a7ac80a6-d3d9-4b04-9b9f-ead1723af09f'),
11+
sponsors: Id.Id('6860bfac-f703-4289-b789-972d0aaf3abe'),
1212
},
1313
},
1414
Company: {
15-
typeIds: [Id.Id('b0220a78-9205-4e5e-9bf1-c03ee0791e23')],
15+
typeIds: [Id.Id('6c504df5-1a8f-43d1-bf2d-1ef9fa5b08b5')],
1616
properties: {
1717
name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'),
1818
},
1919
relations: {
20-
jobOffers: Id.Id('7ca8063c-3664-479b-912d-1b3b86af2bf4'),
20+
jobOffers: Id.Id('1203064e-9741-4235-89d4-97f4b22eddfb'),
2121
},
2222
},
2323
JobOffer: {
24-
typeIds: [Id.Id('99e1733b-661d-4edb-a253-98ff4b7747d0')],
24+
typeIds: [Id.Id('f60585af-71b6-4674-9a26-b74ca6c1cceb')],
2525
properties: {
2626
name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'),
27-
salary: Id.Id('5ecfb4e5-09eb-437d-9c3c-e9e7395d52aa'),
27+
salary: Id.Id('baa36ac9-78ac-4cf7-8394-6b2d3006bebe'),
2828
},
2929
},
3030

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const Route = createLazyFileRoute('/playground')({
99
});
1010

1111
function RouteComponent() {
12-
const space = 'a57cd482-6dd3-4ba3-ac44-e2e8ea7a2862';
12+
const space = 'a393e509-ae56-4d99-987c-bed71d9db631';
1313
return (
1414
<HypergraphSpaceProvider space={space}>
1515
<div className="flex flex-col gap-4 max-w-(--breakpoint-sm) mx-auto py-8">

packages/hypergraph-react/src/hooks/use-spaces.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@ import { GEO_API_TESTNET_ENDPOINT } from '../internal/constants.js';
88

99
const publicSpacesQueryDocument = gql`
1010
query Spaces($accountAddress: String!) {
11-
spaces(filter: {
12-
member: { is: $accountAddress }
13-
}) {
11+
spaces(filter: {members: {some: {address: {is: $accountAddress}}}}) {
1412
id
1513
spaceAddress
16-
entity {
14+
page {
1715
name
1816
}
1917
}
@@ -24,7 +22,7 @@ type PublicSpacesQueryResult = {
2422
spaces: {
2523
id: string;
2624
spaceAddress: string;
27-
entity: {
25+
page: {
2826
name: string;
2927
};
3028
}[];
@@ -41,7 +39,7 @@ export const useSpaces = (params: { mode: 'public' | 'private' }) => {
4139
return result?.spaces
4240
? result.spaces.map((space) => ({
4341
id: space.id,
44-
name: space.entity.name,
42+
name: space.page.name,
4543
spaceAddress: space.spaceAddress,
4644
}))
4745
: [];
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export const GEO_API_MAINNET_ENDPOINT = 'https://hypergraph-v2.up.railway.app/graphql';
2-
export const GEO_API_TESTNET_ENDPOINT = 'https://hypergraph-v2-testnet.up.railway.app/graphql';
2+
export const GEO_API_TESTNET_ENDPOINT = 'https://v2-postgraphile.up.railway.app/graphql';

packages/hypergraph-react/src/internal/use-delete-entity-public.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ type DeleteEntityPublicParams = {
1010
};
1111

1212
const deleteEntityQueryDocument = gql`
13-
query entityToDelete($entityId: String!, $spaceId: String!) {
14-
entity(id: $entityId, spaceId: $spaceId) {
15-
values {
13+
query entityToDelete($entityId: UUID!, $spaceId: UUID!) {
14+
entity(id: $entityId) {
15+
valuesList(filter: {spaceId: {is: $spaceId}}) {
1616
propertyId
1717
}
18-
relations {
18+
relationsList(filter: {spaceId: {is: $spaceId}}) {
1919
id
2020
}
2121
}
@@ -24,10 +24,10 @@ query entityToDelete($entityId: String!, $spaceId: String!) {
2424

2525
type EntityToDeleteQueryResult = {
2626
entity: {
27-
values: {
27+
valuesList: {
2828
propertyId: string;
2929
}[];
30-
relations: {
30+
relationsList: {
3131
id: string;
3232
}[];
3333
};
@@ -45,14 +45,14 @@ export const useDeleteEntityPublic = <S extends Entity.AnyNoContext>(type: S, {
4545
if (!result) {
4646
return { success: false, error: 'Entity not found' };
4747
}
48-
const { values, relations } = result.entity;
48+
const { valuesList, relationsList } = result.entity;
4949
const ops: Op[] = [];
5050
const { ops: unsetEntityValuesOps } = Graph.unsetEntityValues({
5151
id,
52-
properties: values.map(({ propertyId }) => propertyId),
52+
properties: valuesList.map(({ propertyId }) => propertyId),
5353
});
5454
ops.push(...unsetEntityValuesOps);
55-
for (const relation of relations) {
55+
for (const relation of relationsList) {
5656
const { ops: deleteRelationOps } = Graph.deleteRelation({ id: relation.id });
5757
ops.push(...deleteRelationOps);
5858
}

0 commit comments

Comments
 (0)