@@ -19,10 +19,11 @@ export type FindManyPublicParams<S extends Schema.Schema.AnyNoContext> = {
1919 direction : 'asc' | 'desc' ;
2020 }
2121 | undefined ;
22+ backlinksTotalCountsTypeId1 ?: string | undefined ;
2223} ;
2324
2425const entitiesQueryDocumentLevel0 = gql `
25- query entities($spaceId: UUID!, $typeIds: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int) {
26+ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $backlinksTotalCountsTypeId1: UUID, $backlinksTotalCountsTypeId1Present: Boolean! ) {
2627 entities(
2728 filter: { and: [{
2829 relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}},
@@ -41,12 +42,15 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $first: Int, $filter: Entity
4142 time
4243 point
4344 }
45+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
46+ totalCount
47+ }
4448 }
4549}
4650` ;
4751
4852const entitiesQueryDocumentLevel1 = gql `
49- query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int) {
53+ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $backlinksTotalCountsTypeId1: UUID, $backlinksTotalCountsTypeId1Present: Boolean! ) {
5054 entities(
5155 first: $first
5256 filter: { and: [{
@@ -65,6 +69,9 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
6569 time
6670 point
6771 }
72+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
73+ totalCount
74+ }
6875 relationsList(
6976 filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}},
7077 ) {
@@ -98,7 +105,7 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
98105` ;
99106
100107const entitiesQueryDocumentLevel2 = gql `
101- query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $relationTypeIdsLevel2: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int) {
108+ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $relationTypeIdsLevel2: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $backlinksTotalCountsTypeId1: UUID, $backlinksTotalCountsTypeId1Present: Boolean! ) {
102109 entities(
103110 first: $first
104111 filter: { and: [{
@@ -117,6 +124,9 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
117124 time
118125 point
119126 }
127+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
128+ totalCount
129+ }
120130 relationsList(
121131 filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}},
122132 ) {
@@ -142,6 +152,9 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
142152 time
143153 point
144154 }
155+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
156+ totalCount
157+ }
145158 relationsList(
146159 filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel2}},
147160 # filter: {spaceId: {is: $spaceId}, toEntity: {relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $relationTypeIdsLevel2}}}}}
@@ -179,7 +192,7 @@ query entities($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUI
179192` ;
180193
181194const entitiesOrderedByPropertyQueryDocumentLevel0 = gql `
182- query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $propertyId: UUID!, $sortDirection: SortOrder!) {
195+ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $propertyId: UUID!, $sortDirection: SortOrder!, $backlinksTotalCountsTypeId1: UUID, $backlinksTotalCountsTypeId1Present: Boolean! ) {
183196 entities: entitiesOrderedByProperty(
184197 filter: { and: [{
185198 relations: {some: {typeId: {is: "8f151ba4-de20-4e3c-9cb4-99ddf96f48f1"}, toEntityId: {in: $typeIds}}},
@@ -200,12 +213,15 @@ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $first: Int
200213 time
201214 point
202215 }
216+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
217+ totalCount
218+ }
203219 }
204220}
205221` ;
206222
207223const entitiesOrderedByPropertyQueryDocumentLevel1 = gql `
208- query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $propertyId: UUID!, $sortDirection: SortOrder!) {
224+ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $propertyId: UUID!, $sortDirection: SortOrder!, $backlinksTotalCountsTypeId1: UUID, $backlinksTotalCountsTypeId1Present: Boolean! ) {
209225 entities: entitiesOrderedByProperty(
210226 first: $first
211227 filter: { and: [{
@@ -226,6 +242,9 @@ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTy
226242 time
227243 point
228244 }
245+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
246+ totalCount
247+ }
229248 relationsList(
230249 filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}},
231250 ) {
@@ -259,7 +278,7 @@ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTy
259278` ;
260279
261280const entitiesOrderedByPropertyQueryDocumentLevel2 = gql `
262- query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $relationTypeIdsLevel2: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $propertyId: UUID!, $sortDirection: SortOrder!) {
281+ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTypeIdsLevel1: [UUID!]!, $relationTypeIdsLevel2: [UUID!]!, $first: Int, $filter: EntityFilter!, $offset: Int, $propertyId: UUID!, $sortDirection: SortOrder!, $backlinksTotalCountsTypeId1: UUID, $backlinksTotalCountsTypeId1Present: Boolean! ) {
263282 entities: entitiesOrderedByProperty(
264283 first: $first
265284 filter: { and: [{
@@ -280,6 +299,9 @@ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTy
280299 time
281300 point
282301 }
302+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
303+ totalCount
304+ }
283305 relationsList(
284306 filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel1}},
285307 ) {
@@ -305,6 +327,9 @@ query entitiesOrderedByProperty($spaceId: UUID!, $typeIds: [UUID!]!, $relationTy
305327 time
306328 point
307329 }
330+ backlinksTotalCountsTypeId1: backlinks(filter: { spaceId: {is: $spaceId}, fromEntity: { typeIds: { is: [$backlinksTotalCountsTypeId1] } }}) @include(if: $backlinksTotalCountsTypeId1Present) {
331+ totalCount
332+ }
308333 relationsList(
309334 filter: {spaceId: {is: $spaceId}, typeId:{ in: $relationTypeIdsLevel2}},
310335 ) {
@@ -352,6 +377,9 @@ type EntityQueryResult = {
352377 time : string ;
353378 point : string ;
354379 } [ ] ;
380+ backlinksTotalCountsTypeId1 : {
381+ totalCount : number ;
382+ } | null ;
355383 relationsList : {
356384 id : string ;
357385 entity : {
@@ -412,7 +440,7 @@ type GraphSortDirection = 'ASC' | 'DESC';
412440export const parseResult = < S extends Schema . Schema . AnyNoContext > ( queryData : EntityQueryResult , type : S ) => {
413441 const schemaWithId = Utils . addIdSchemaField ( type ) ;
414442 const decode = Schema . decodeUnknownEither ( schemaWithId ) ;
415- const data : Entity . Entity < S > [ ] = [ ] ;
443+ const data : ( Entity . Entity < S > & { backlinksTotalCountsTypeId1 ?: number } ) [ ] = [ ] ;
416444 const invalidEntities : Record < string , unknown > [ ] = [ ] ;
417445
418446 for ( const queryEntity of queryData . entities ) {
@@ -454,7 +482,11 @@ export const parseResult = <S extends Schema.Schema.AnyNoContext>(queryData: Ent
454482
455483 if ( Either . isRight ( decodeResult ) ) {
456484 // injecting the schema to the entity to be able to access it in the preparePublish function
457- data . push ( { ...decodeResult . right , __schema : type } ) ;
485+ data . push ( {
486+ ...decodeResult . right ,
487+ __schema : type ,
488+ backlinksTotalCountsTypeId1 : queryEntity . backlinksTotalCountsTypeId1 ?. totalCount ,
489+ } ) ;
458490 } else {
459491 invalidEntities . push ( rawEntity ) ;
460492 }
@@ -466,7 +498,7 @@ export const findManyPublic = async <S extends Schema.Schema.AnyNoContext>(
466498 type : S ,
467499 params ?: FindManyPublicParams < S > ,
468500) => {
469- const { filter, include, space, first = 100 , offset = 0 , orderBy } = params ?? { } ;
501+ const { filter, include, space, first = 100 , offset = 0 , orderBy, backlinksTotalCountsTypeId1 } = params ?? { } ;
470502
471503 // constructing the relation type ids for the query
472504 const relationTypeIds = Utils . getRelationTypeIds ( type , include ) ;
@@ -534,6 +566,13 @@ export const findManyPublic = async <S extends Schema.Schema.AnyNoContext>(
534566 queryVariables . sortDirection = sortDirection ;
535567 }
536568
569+ if ( backlinksTotalCountsTypeId1 ) {
570+ queryVariables . backlinksTotalCountsTypeId1 = backlinksTotalCountsTypeId1 ;
571+ queryVariables . backlinksTotalCountsTypeId1Present = true ;
572+ } else {
573+ queryVariables . backlinksTotalCountsTypeId1Present = false ;
574+ }
575+
537576 const result = await request < EntityQueryResult > ( `${ Graph . TESTNET_API_ORIGIN } /graphql` , queryDocument , queryVariables ) ;
538577
539578 const { data, invalidEntities } = parseResult ( result , type ) ;
0 commit comments