@@ -2,7 +2,7 @@ import { Constants, Utils } from '@graphprotocol/hypergraph';
22import * as Option from 'effect/Option' ;
33import type * as Schema from 'effect/Schema' ;
44import * as SchemaAST from 'effect/SchemaAST' ;
5- import type { EntityInclude , RelationIncludeBranch } from '../entity/types.js' ;
5+ import type { EntityInclude , RelationIncludeBranch , RelationSpacesOverride } from '../entity/types.js' ;
66
77export type RelationListField = 'relations' | 'backlinks' ;
88
@@ -12,6 +12,8 @@ export type RelationTypeIdInfo = {
1212 listField : RelationListField ;
1313 includeNodes : boolean ;
1414 includeTotalCount : boolean ;
15+ relationSpaces ?: RelationSpacesOverride ;
16+ valueSpaces ?: RelationSpacesOverride ;
1517 children ?: RelationTypeIdInfo [ ] ;
1618} ;
1719
@@ -35,8 +37,9 @@ export const getRelationTypeIds = <S extends Schema.Schema.AnyNoContext>(
3537 const result = SchemaAST . getAnnotation < string > ( Constants . PropertyIdSymbol ) ( prop . type ) ;
3638 if ( Option . isSome ( result ) ) {
3739 const propertyName = String ( prop . name ) ;
38- const includeBranch = include ?. [ propertyName as keyof EntityInclude < S > ] as RelationIncludeBranch | undefined ;
39- const includeNodes = isRelationIncludeBranch ( includeBranch ) ;
40+ const includeBranchCandidate = include ?. [ propertyName as keyof EntityInclude < S > ] ;
41+ const includeBranch = isRelationIncludeBranch ( includeBranchCandidate ) ? includeBranchCandidate : undefined ;
42+ const includeNodes = Boolean ( includeBranch ) ;
4043 const includeTotalCount = hasTotalCountFlag ( include as Record < string , unknown > | undefined , propertyName ) ;
4144
4245 if ( ! includeNodes && ! includeTotalCount ) {
@@ -53,6 +56,8 @@ export const getRelationTypeIds = <S extends Schema.Schema.AnyNoContext>(
5356 listField,
5457 includeNodes,
5558 includeTotalCount,
59+ relationSpaces : includeBranch ?. _config ?. relationSpaces ,
60+ valueSpaces : includeBranch ?. _config ?. valueSpaces ,
5661 } ;
5762 const nestedRelations : RelationTypeIdInfo [ ] = [ ] ;
5863
@@ -78,8 +83,11 @@ export const getRelationTypeIds = <S extends Schema.Schema.AnyNoContext>(
7883
7984 const nestedResult = SchemaAST . getAnnotation < string > ( Constants . PropertyIdSymbol ) ( nestedProp . type ) ;
8085 const nestedPropertyName = String ( nestedProp . name ) ;
81- const nestedIncludeBranch = includeBranch ?. [ nestedPropertyName ] ;
82- const nestedIncludeNodes = isRelationIncludeBranch ( nestedIncludeBranch ) ;
86+ const nestedIncludeBranchCandidate = includeBranch ?. [ nestedPropertyName ] ;
87+ const nestedIncludeBranch = isRelationIncludeBranch ( nestedIncludeBranchCandidate )
88+ ? nestedIncludeBranchCandidate
89+ : undefined ;
90+ const nestedIncludeNodes = Boolean ( nestedIncludeBranch ) ;
8391 const nestedIncludeTotalCount = hasTotalCountFlag (
8492 includeBranch as Record < string , unknown > | undefined ,
8593 nestedPropertyName ,
@@ -96,6 +104,8 @@ export const getRelationTypeIds = <S extends Schema.Schema.AnyNoContext>(
96104 listField : nestedListField ,
97105 includeNodes : nestedIncludeNodes ,
98106 includeTotalCount : nestedIncludeTotalCount ,
107+ relationSpaces : nestedIncludeBranch ?. _config ?. relationSpaces ,
108+ valueSpaces : nestedIncludeBranch ?. _config ?. valueSpaces ,
99109 } ;
100110 nestedRelations . push ( nestedInfo ) ;
101111 }
0 commit comments