diff --git a/apps/connect/.env.development b/apps/connect/.env.development index 98b5f6a0..a0fe5ea0 100644 --- a/apps/connect/.env.development +++ b/apps/connect/.env.development @@ -1,6 +1,6 @@ VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="http://localhost:3030" VITE_HYPERGRAPH_CHAIN="geo-testnet" -VITE_HYPERGRAPH_API_URL="https://hypergraph-v2-testnet.up.railway.app/graphql" +VITE_HYPERGRAPH_API_URL="https://v2-postgraphile.up.railway.app/graphql" VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz" VITE_PRIVY_APP_ID="cmbhnmo1x000bla0mxudtd8z9" VITE_PRIVY_PROVIDERS="development" diff --git a/apps/connect/.env.production b/apps/connect/.env.production index 944ad88e..5141cf61 100644 --- a/apps/connect/.env.production +++ b/apps/connect/.env.production @@ -1,7 +1,7 @@ # VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="https://syncserver.hypergraph.thegraph.com" VITE_HYPERGRAPH_SYNC_SERVER_ORIGIN="https://hypergraph.fly.dev" VITE_HYPERGRAPH_CHAIN="geo-testnet" -VITE_HYPERGRAPH_API_URL="https://hypergraph-v2-testnet.up.railway.app/graphql" +VITE_HYPERGRAPH_API_URL="https://v2-postgraphile.up.railway.app/graphql" VITE_HYPERGRAPH_RPC_URL="https://rpc-geo-test-zc16z3tcvf.t.conduit.xyz" VITE_PRIVY_APP_ID="cmcccikza007bjy0niawgutl0" VITE_PRIVY_PROVIDERS="production" \ No newline at end of file diff --git a/apps/connect/src/hooks/use-public-spaces.ts b/apps/connect/src/hooks/use-public-spaces.ts index 87bde7b8..194e81fd 100644 --- a/apps/connect/src/hooks/use-public-spaces.ts +++ b/apps/connect/src/hooks/use-public-spaces.ts @@ -4,12 +4,12 @@ import { gql, request } from 'graphql-request'; const publicSpacesQueryDocument = gql` query Spaces($accountAddress: String!) { - spaces(filter: { member: { is: $accountAddress } }) { + spaces(filter: {members: {some: {address: {is: $accountAddress}}}}) { id type mainVotingAddress personalAddress - entity { + page { name } } @@ -21,7 +21,7 @@ type SpaceQueryResult = { type: string; mainVotingAddress: string; personalAddress: string; - entity: { + page: { name: string; }; }; @@ -50,7 +50,7 @@ export const usePublicSpaces = (url: string): UseQueryResult ({ id: space.id, - name: space.entity.name, + name: space.page.name, type: space.type, mainVotingAddress: space.mainVotingAddress, personalAddress: space.personalAddress, diff --git a/apps/events/src/components/create-events.tsx b/apps/events/src/components/create-events.tsx index cbdbec24..d44730e8 100644 --- a/apps/events/src/components/create-events.tsx +++ b/apps/events/src/components/create-events.tsx @@ -47,7 +47,9 @@ const createEvents = async ({ }); ops.push(...createCompanyTypeOps); - const { ops: createEventTypeOps } = Graph.createEntity({ + console.log('companyTypeId', companyTypeId); + + const { ops: createEventTypeOps, id: eventTypeId } = Graph.createEntity({ name: 'My Test Event', types: mapping.Event.typeIds, relations: { @@ -56,13 +58,15 @@ const createEvents = async ({ }); ops.push(...createEventTypeOps); + console.log('eventTypeId', eventTypeId); + const result = await publishOps({ ops, walletClient: smartSessionClient, space, name: 'Create Job Offers, Companies and Events', }); - console.log('result', result); + console.log('result', result, ops); alert('Events created'); } catch (error) { console.error('error', error); diff --git a/apps/events/src/components/playground.tsx b/apps/events/src/components/playground.tsx index ae297706..03c7b49f 100644 --- a/apps/events/src/components/playground.tsx +++ b/apps/events/src/components/playground.tsx @@ -47,7 +47,7 @@ export const Playground = () => { const { success, cid, txResult } = await createEntity( { name: 'Test Event 42 by Nik', - sponsors: ['347676a1-7cef-47dc-b6a7-c94fc6237dcd'], + sponsors: [], }, { walletClient }, ); diff --git a/apps/events/src/mapping.ts b/apps/events/src/mapping.ts index b3b06cab..49b98e46 100644 --- a/apps/events/src/mapping.ts +++ b/apps/events/src/mapping.ts @@ -3,28 +3,28 @@ import type { Mapping } from '@graphprotocol/hypergraph'; export const mapping: Mapping = { Event: { - typeIds: [Id.Id('407d9e8a-c703-4fb4-830d-98c758c8564e')], + typeIds: [Id.Id('7f9562d4-034d-4385-bf5c-f02cdebba47a')], properties: { name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'), }, relations: { - sponsors: Id.Id('a7ac80a6-d3d9-4b04-9b9f-ead1723af09f'), + sponsors: Id.Id('6860bfac-f703-4289-b789-972d0aaf3abe'), }, }, Company: { - typeIds: [Id.Id('b0220a78-9205-4e5e-9bf1-c03ee0791e23')], + typeIds: [Id.Id('6c504df5-1a8f-43d1-bf2d-1ef9fa5b08b5')], properties: { name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'), }, relations: { - jobOffers: Id.Id('7ca8063c-3664-479b-912d-1b3b86af2bf4'), + jobOffers: Id.Id('1203064e-9741-4235-89d4-97f4b22eddfb'), }, }, JobOffer: { - typeIds: [Id.Id('99e1733b-661d-4edb-a253-98ff4b7747d0')], + typeIds: [Id.Id('f60585af-71b6-4674-9a26-b74ca6c1cceb')], properties: { name: Id.Id('a126ca53-0c8e-48d5-b888-82c734c38935'), - salary: Id.Id('5ecfb4e5-09eb-437d-9c3c-e9e7395d52aa'), + salary: Id.Id('baa36ac9-78ac-4cf7-8394-6b2d3006bebe'), }, }, diff --git a/apps/events/src/routes/playground.lazy.tsx b/apps/events/src/routes/playground.lazy.tsx index c957ed91..acc114c6 100644 --- a/apps/events/src/routes/playground.lazy.tsx +++ b/apps/events/src/routes/playground.lazy.tsx @@ -9,7 +9,7 @@ export const Route = createLazyFileRoute('/playground')({ }); function RouteComponent() { - const space = 'a57cd482-6dd3-4ba3-ac44-e2e8ea7a2862'; + const space = 'a393e509-ae56-4d99-987c-bed71d9db631'; return (
diff --git a/packages/hypergraph-react/src/hooks/use-spaces.ts b/packages/hypergraph-react/src/hooks/use-spaces.ts index a9027ee3..31684d7e 100644 --- a/packages/hypergraph-react/src/hooks/use-spaces.ts +++ b/packages/hypergraph-react/src/hooks/use-spaces.ts @@ -8,12 +8,10 @@ import { GEO_API_TESTNET_ENDPOINT } from '../internal/constants.js'; const publicSpacesQueryDocument = gql` query Spaces($accountAddress: String!) { - spaces(filter: { - member: { is: $accountAddress } - }) { + spaces(filter: {members: {some: {address: {is: $accountAddress}}}}) { id spaceAddress - entity { + page { name } } @@ -24,7 +22,7 @@ type PublicSpacesQueryResult = { spaces: { id: string; spaceAddress: string; - entity: { + page: { name: string; }; }[]; @@ -41,7 +39,7 @@ export const useSpaces = (params: { mode: 'public' | 'private' }) => { return result?.spaces ? result.spaces.map((space) => ({ id: space.id, - name: space.entity.name, + name: space.page.name, spaceAddress: space.spaceAddress, })) : []; diff --git a/packages/hypergraph-react/src/internal/constants.ts b/packages/hypergraph-react/src/internal/constants.ts index 3eb9108f..e0198327 100644 --- a/packages/hypergraph-react/src/internal/constants.ts +++ b/packages/hypergraph-react/src/internal/constants.ts @@ -1,2 +1,2 @@ export const GEO_API_MAINNET_ENDPOINT = 'https://hypergraph-v2.up.railway.app/graphql'; -export const GEO_API_TESTNET_ENDPOINT = 'https://hypergraph-v2-testnet.up.railway.app/graphql'; +export const GEO_API_TESTNET_ENDPOINT = 'https://v2-postgraphile.up.railway.app/graphql'; diff --git a/packages/hypergraph-react/src/internal/use-delete-entity-public.tsx b/packages/hypergraph-react/src/internal/use-delete-entity-public.tsx index 85be045e..954fd403 100644 --- a/packages/hypergraph-react/src/internal/use-delete-entity-public.tsx +++ b/packages/hypergraph-react/src/internal/use-delete-entity-public.tsx @@ -10,12 +10,12 @@ type DeleteEntityPublicParams = { }; const deleteEntityQueryDocument = gql` -query entityToDelete($entityId: String!, $spaceId: String!) { - entity(id: $entityId, spaceId: $spaceId) { - values { +query entityToDelete($entityId: UUID!, $spaceId: UUID!) { + entity(id: $entityId) { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId } - relations { + relationsList(filter: {spaceId: {is: $spaceId}}) { id } } @@ -24,10 +24,10 @@ query entityToDelete($entityId: String!, $spaceId: String!) { type EntityToDeleteQueryResult = { entity: { - values: { + valuesList: { propertyId: string; }[]; - relations: { + relationsList: { id: string; }[]; }; @@ -45,14 +45,14 @@ export const useDeleteEntityPublic = (type: S, { if (!result) { return { success: false, error: 'Entity not found' }; } - const { values, relations } = result.entity; + const { valuesList, relationsList } = result.entity; const ops: Op[] = []; const { ops: unsetEntityValuesOps } = Graph.unsetEntityValues({ id, - properties: values.map(({ propertyId }) => propertyId), + properties: valuesList.map(({ propertyId }) => propertyId), }); ops.push(...unsetEntityValuesOps); - for (const relation of relations) { + for (const relation of relationsList) { const { ops: deleteRelationOps } = Graph.deleteRelation({ id: relation.id }); ops.push(...deleteRelationOps); } diff --git a/packages/hypergraph-react/src/internal/use-public-space.tsx b/packages/hypergraph-react/src/internal/use-public-space.tsx index e1e73529..006d7ff8 100644 --- a/packages/hypergraph-react/src/internal/use-public-space.tsx +++ b/packages/hypergraph-react/src/internal/use-public-space.tsx @@ -3,9 +3,9 @@ import { gql, request } from 'graphql-request'; import { GEO_API_TESTNET_ENDPOINT } from '../internal/constants.js'; const spaceQueryDocument = gql` -query Space($spaceId: String!) { +query Space($spaceId: UUID!) { space(id: $spaceId) { - entity { + page { name } } @@ -14,7 +14,7 @@ query Space($spaceId: String!) { type SpaceQueryResult = { space: { - entity: { + page: { name: string; }; } | null; @@ -27,9 +27,9 @@ export const usePublicSpace = ({ spaceId, enabled }: { spaceId: string; enabled: const result = await request(GEO_API_TESTNET_ENDPOINT, spaceQueryDocument, { spaceId, }); - return result?.space?.entity + return result?.space?.page ? { - name: result.space.entity.name, + name: result.space.page.name, } : null; }, diff --git a/packages/hypergraph-react/src/internal/use-query-public.tsx b/packages/hypergraph-react/src/internal/use-query-public.tsx index a9c698aa..40125c24 100644 --- a/packages/hypergraph-react/src/internal/use-query-public.tsx +++ b/packages/hypergraph-react/src/internal/use-query-public.tsx @@ -10,13 +10,14 @@ import { GEO_API_TESTNET_ENDPOINT } from './constants.js'; import type { QueryPublicParams } from './types.js'; const entitiesQueryDocumentLevel0 = gql` -query entities($spaceId: String!, $typeIds: [String!]!) { - entities(spaceId: $spaceId, filter: { - types: { in: $typeIds } - }) { +query entities($spaceId: UUID!, $typeIds: [UUID!]!) { + entities( + filter: { + relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}}, spaceIds: {in: [$spaceId]}}, + ) { id name - values { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId value } @@ -25,84 +26,68 @@ query entities($spaceId: String!, $typeIds: [String!]!) { `; const entitiesQueryDocumentLevel1 = gql` -query entities($spaceId: String!, $typeIds: [String!]!, $relationTypeIdsLevel1: [String!]!) { - entities(spaceId: $spaceId, filter: { - types: { in: $typeIds } - }) { +query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!) { + entities(filter: { + relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}}, spaceIds: {in: [$spaceId]}}) { id name - values { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId value } - relations(filter: { - type: { in: $relationTypeIdsLevel1 } - }) { - to { + relationsList( + filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}}, + ) { + toEntity { id name - values { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId value } } - type { - id - entity { - name - } - } + typeId } } } `; const entitiesQueryDocumentLevel2 = gql` -query entities($spaceId: String!, $typeIds: [String!]!, $relationTypeIdsLevel1: [String!]!, $relationTypeIdsLevel2: [String!]!) { - entities(spaceId: $spaceId, filter: { - types: { in: $typeIds } - }) { +query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $relationTypeIdsLevel2: [UUID!]!) { + entities(filter: { + relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}}, spaceIds: {in: [$spaceId]}}) { id name - values { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId value } - relations(filter: { - type: { in: $relationTypeIdsLevel1 } - }) { - to { + relationsList( + filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}}, + ) { + toEntity { id name - values { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId value } - relations(filter: { - type: { in: $relationTypeIdsLevel2 } - }) { - to { + relationsList( + filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel2}}, + # filter: {spaceId: {is: $spaceId}, toEntity: {relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $relationTypeIdsLevel2}}}}} + ) { + toEntity { id name - values { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId value } } - type { - id - entity { - name - } - } - } - } - type { - id - entity { - name + typeId } } + typeId } } } @@ -112,41 +97,31 @@ type EntityQueryResult = { entities: { id: string; name: string; - values: { + valuesList: { propertyId: string; value: string; }[]; - relations: { - to: { + relationsList: { + toEntity: { id: string; name: string; - values: { + valuesList: { propertyId: string; value: string; }[]; - relations: { - to: { + relationsList: { + toEntity: { id: string; name: string; - values: { + valuesList: { propertyId: string; value: string; }[]; }; - type: { - id: string; - entity: { - name: string; - }; - }; + typeId: string; }[]; }; - type: { - id: string; - entity: { - name: string; - }; - }; + typeId: string; }[]; }[]; }; @@ -158,18 +133,13 @@ type EntityQueryResult = { type RecursiveQueryEntity = { id: string; name: string; - values?: { + valuesList?: { propertyId: string; value: string; }[]; - relations?: { - to: RecursiveQueryEntity; - type: { - id: string; - entity: { - name: string; - }; - }; + relationsList?: { + toEntity: RecursiveQueryEntity; + typeId: string; }[]; }; @@ -205,7 +175,7 @@ const convertRelations = ( const rawEntity: Record = {}; for (const [key, relationId] of Object.entries(mappingEntry?.relations ?? {})) { - const properties = (queryEntity.relations ?? []).filter((a) => a.type?.id === relationId); + const properties = (queryEntity.relationsList ?? []).filter((a) => a.typeId === relationId); if (properties.length === 0) { rawEntity[key] = [] as unknown[]; continue; @@ -233,22 +203,21 @@ const convertRelations = ( } const newRelationEntities = properties.map((propertyEntry) => { + // @ts-expect-error TODO: properly access the type.name + const type = field.value; + let rawEntity: Record = { - id: propertyEntry.to.id, - name: propertyEntry.to.name, - type: propertyEntry.type.id, + id: propertyEntry.toEntity.id, + name: propertyEntry.toEntity.name, // TODO: should be determined by the actual value __deleted: false, // TODO: should be determined by the actual value __version: '', }; - // @ts-expect-error TODO: properly access the type.name - const type = field.value; - // take the mappingEntry and assign the attributes to the rawEntity for (const [key, value] of Object.entries(relationMappingEntry?.properties ?? {})) { - const property = propertyEntry.to.values?.find((a) => a.propertyId === value); + const property = propertyEntry.toEntity.valuesList?.find((a) => a.propertyId === value); if (property) { rawEntity[key] = convertPropertyValue(property, key, type); } @@ -256,7 +225,7 @@ const convertRelations = ( rawEntity = { ...rawEntity, - ...convertRelations(propertyEntry.to, type, relationMappingEntry, mapping), + ...convertRelations(propertyEntry.toEntity, type, relationMappingEntry, mapping), }; return rawEntity; @@ -293,7 +262,7 @@ export const parseResult = ( // take the mappingEntry and assign the attributes to the rawEntity for (const [key, value] of Object.entries(mappingEntry?.properties ?? {})) { - const property = queryEntity.values.find((a) => a.propertyId === value); + const property = queryEntity.valuesList.find((a) => a.propertyId === value); if (property) { rawEntity[key] = convertPropertyValue(property, key, type); } diff --git a/packages/hypergraph-react/src/prepare-publish.ts b/packages/hypergraph-react/src/prepare-publish.ts index dc6547cd..52f5c8b6 100644 --- a/packages/hypergraph-react/src/prepare-publish.ts +++ b/packages/hypergraph-react/src/prepare-publish.ts @@ -17,13 +17,13 @@ export type PreparePublishParams = { }; const entityToPublishQueryDocument = gql` -query entityToPublish($entityId: String!, $spaceId: String!) { - entity(id: $entityId, spaceId: $spaceId) { - values { +query entityToPublish($entityId: UUID!, $spaceId: UUID!) { + entity(id: $entityId) { + valuesList(filter: {spaceId: {is: $spaceId}}) { propertyId value } - relations { + relationsList(filter: {spaceId: {is: $spaceId}}) { id } } @@ -32,11 +32,11 @@ query entityToPublish($entityId: String!, $spaceId: String!) { type EntityToPublishQueryResult = { entity: { - values: { + valuesList: { propertyId: string; value: string; }[]; - relations: { + relationsList: { id: string; }[]; }; @@ -113,7 +113,7 @@ export const preparePublish = async ({ serializedValue = Graph.serializeNumber(entity[key]); } - const existingValue = data.entity.values.find((value) => value.propertyId === propertyId); + const existingValue = data.entity.valuesList.find((value) => value.propertyId === propertyId); if (serializedValue !== existingValue?.value) { values.push({ property: propertyId, value: serializedValue }); diff --git a/packages/hypergraph-react/src/publish-ops.ts b/packages/hypergraph-react/src/publish-ops.ts index c70138bb..3279f39b 100644 --- a/packages/hypergraph-react/src/publish-ops.ts +++ b/packages/hypergraph-react/src/publish-ops.ts @@ -34,7 +34,7 @@ export const publishOps = async ({ name, ops, walletClient, space }: PublishPara const cid = publishResult.cid; // This returns the correct contract address and calldata depending on the space id - const result = await fetch(`https://hypergraph-v2-testnet.up.railway.app/space/${space}/edit/calldata`, { + const result = await fetch(`https://v2-postgraphile.up.railway.app/space/${space}/edit/calldata`, { method: 'POST', body: JSON.stringify({ cid }), });