@@ -14,11 +14,10 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!) {
1414 entities(
1515 filter: {
1616 relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}}, spaceIds: {in: [$spaceId]}},
17- first: 100
1817 ) {
1918 id
2019 name
21- valuesList {
20+ valuesList(filter: {spaceId: {is: $spaceId}}) {
2221 propertyId
2322 value
2423 }
@@ -37,21 +36,17 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
3736 value
3837 }
3938 relationsList(
40- filter: {spaceId: {is: $spaceId}, toEntity: {relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $relationTypeIdsLevel1}}}}},
41- first: 100
39+ filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}},
4240 ) {
4341 toEntity {
4442 id
4543 name
46- valuesList {
44+ valuesList(filter: {spaceId: {is: $spaceId}}) {
4745 propertyId
4846 value
4947 }
5048 }
51- type {
52- id
53- name
54- }
49+ typeId
5550 }
5651 }
5752}
@@ -60,27 +55,26 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
6055const entitiesQueryDocumentLevel2 = gql `
6156query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $relationTypeIdsLevel2: [UUID!]!) {
6257 entities(filter: {
63- relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}}, spaceIds: {in: [$spaceId]}},
64- first: 100
65- ) {
58+ relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}}, spaceIds: {in: [$spaceId]}}) {
6659 id
6760 name
6861 valuesList(filter: {spaceId: {is: $spaceId}}) {
6962 propertyId
7063 value
7164 }
7265 relationsList(
73- filter: {spaceId: {is: $spaceId}, toEntity: {relations: {some: { typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: { in: $relationTypeIdsLevel1}}}}}
66+ filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}},
7467 ) {
7568 toEntity {
7669 id
7770 name
78- valuesList {
71+ valuesList(filter: {spaceId: {is: $spaceId}}) {
7972 propertyId
8073 value
8174 }
8275 relationsList(
83- filter: {spaceId: {is: $spaceId}, toEntity: {relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $relationTypeIdsLevel2}}}}}
76+ filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel2}},
77+ # filter: {spaceId: {is: $spaceId}, toEntity: {relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $relationTypeIdsLevel2}}}}}
8478 ) {
8579 toEntity {
8680 id
@@ -90,16 +84,10 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
9084 value
9185 }
9286 }
93- type {
94- id
95- name
96- }
87+ typeId
9788 }
9889 }
99- type {
100- id
101- name
102- }
90+ typeId
10391 }
10492 }
10593}
@@ -114,36 +102,26 @@ type EntityQueryResult = {
114102 value : string ;
115103 } [ ] ;
116104 relationsList : {
117- to : {
105+ toEntity : {
118106 id : string ;
119107 name : string ;
120108 valuesList : {
121109 propertyId : string ;
122110 value : string ;
123111 } [ ] ;
124112 relationsList : {
125- to : {
113+ toEntity : {
126114 id : string ;
127115 name : string ;
128116 valuesList : {
129117 propertyId : string ;
130118 value : string ;
131119 } [ ] ;
132120 } ;
133- type : {
134- id : string ;
135- entity : {
136- name : string ;
137- } ;
138- } ;
121+ typeId : string ;
139122 } [ ] ;
140123 } ;
141- type : {
142- id : string ;
143- entity : {
144- name : string ;
145- } ;
146- } ;
124+ typeId : string ;
147125 } [ ] ;
148126 } [ ] ;
149127} ;
@@ -160,13 +138,8 @@ type RecursiveQueryEntity = {
160138 value : string ;
161139 } [ ] ;
162140 relationsList ?: {
163- to : RecursiveQueryEntity ;
164- type : {
165- id : string ;
166- entity : {
167- name : string ;
168- } ;
169- } ;
141+ toEntity : RecursiveQueryEntity ;
142+ typeId : string ;
170143 } [ ] ;
171144} ;
172145
@@ -202,7 +175,7 @@ const convertRelations = <S extends Entity.AnyNoContext>(
202175 const rawEntity : Record < string , string | boolean | number | unknown [ ] | URL | Date > = { } ;
203176
204177 for ( const [ key , relationId ] of Object . entries ( mappingEntry ?. relations ?? { } ) ) {
205- const properties = ( queryEntity . relationsList ?? [ ] ) . filter ( ( a ) => a . type ?. id === relationId ) ;
178+ const properties = ( queryEntity . relationsList ?? [ ] ) . filter ( ( a ) => a . typeId === relationId ) ;
206179 if ( properties . length === 0 ) {
207180 rawEntity [ key ] = [ ] as unknown [ ] ;
208181 continue ;
@@ -230,30 +203,29 @@ const convertRelations = <S extends Entity.AnyNoContext>(
230203 }
231204
232205 const newRelationEntities = properties . map ( ( propertyEntry ) => {
206+ // @ts -expect-error TODO: properly access the type.name
207+ const type = field . value ;
208+
233209 let rawEntity : Record < string , string | boolean | number | unknown [ ] | URL | Date > = {
234- id : propertyEntry . to . id ,
235- name : propertyEntry . to . name ,
236- type : propertyEntry . type . id ,
210+ id : propertyEntry . toEntity . id ,
211+ name : propertyEntry . toEntity . name ,
237212 // TODO: should be determined by the actual value
238213 __deleted : false ,
239214 // TODO: should be determined by the actual value
240215 __version : '' ,
241216 } ;
242217
243- // @ts -expect-error TODO: properly access the type.name
244- const type = field . value ;
245-
246218 // take the mappingEntry and assign the attributes to the rawEntity
247219 for ( const [ key , value ] of Object . entries ( relationMappingEntry ?. properties ?? { } ) ) {
248- const property = propertyEntry . to . valuesList ?. find ( ( a ) => a . propertyId === value ) ;
220+ const property = propertyEntry . toEntity . valuesList ?. find ( ( a ) => a . propertyId === value ) ;
249221 if ( property ) {
250222 rawEntity [ key ] = convertPropertyValue ( property , key , type ) ;
251223 }
252224 }
253225
254226 rawEntity = {
255227 ...rawEntity ,
256- ...convertRelations ( propertyEntry . to , type , relationMappingEntry , mapping ) ,
228+ ...convertRelations ( propertyEntry . toEntity , type , relationMappingEntry , mapping ) ,
257229 } ;
258230
259231 return rawEntity ;
0 commit comments