@@ -58,25 +58,29 @@ const buildEntitiesQuery = (
5858 . filter ( Boolean )
5959 . join ( ', ' ) ;
6060
61- const orderByArgs = useOrderBy ? 'propertyId: $propertyId\n sortDirection: $sortDirection\n ' : '' ;
62- const entitySpaceFilter =
63- spaceSelection . mode === 'single'
64- ? 'spaceIds: {in: [$spaceId]},'
65- : spaceSelection . mode === 'many'
66- ? 'spaceIds: {in: $spaceIds},'
67- : '' ;
6861 const valuesListFilter =
6962 spaceSelection . mode === 'single'
7063 ? '(filter: { spaceId: { is: $spaceId } })'
7164 : spaceSelection . mode === 'many'
7265 ? '(filter: { spaceId: { in: $spaceIds } })'
7366 : '' ;
7467
75- return `
68+ // entitiesOrderedByProperty doesn't support the native typeIds filter yet,
69+ // so we fall back to the relation-based filter for orderBy queries
70+ if ( useOrderBy ) {
71+ const orderByArgs = 'propertyId: $propertyId\n sortDirection: $sortDirection\n ' ;
72+ const entitySpaceFilter =
73+ spaceSelection . mode === 'single'
74+ ? 'spaceIds: {in: [$spaceId]},'
75+ : spaceSelection . mode === 'many'
76+ ? 'spaceIds: {in: $spaceIds},'
77+ : '' ;
78+
79+ return `
7680query ${ queryName } (${ variableDefinitions } ) {
7781 entities: ${ queryName } (
7882 ${ orderByArgs } filter: { and: [{
79- relations: {some: {typeId: {is: "8f151ba4de204e3c9cb499ddf96f48f1"}, toEntityId: {in: $typeIds}}},
83+ relations: {some: {typeId: {is: "8f151ba4de204e3c9cb499ddf96f48f1"}, toEntityId: {in: $typeIds}}},
8084 ${ entitySpaceFilter }
8185 }, $filter]}
8286 first: $first
@@ -95,6 +99,39 @@ query ${queryName}(${variableDefinitions}) {
9599 }
96100 ${ level1Relations }
97101 }
102+ }` ;
103+ }
104+
105+ // For the regular entities query, use the native spaceId/spaceIds and typeIds filters
106+ const spaceArg =
107+ spaceSelection . mode === 'single'
108+ ? 'spaceId: $spaceId'
109+ : spaceSelection . mode === 'many'
110+ ? 'spaceIds: {in: $spaceIds}'
111+ : '' ;
112+
113+ return `
114+ query ${ queryName } (${ variableDefinitions } ) {
115+ entities: ${ queryName } (
116+ ${ spaceArg }
117+ typeIds: {in: $typeIds}
118+ filter: $filter
119+ first: $first
120+ offset: $offset
121+ ) {
122+ id
123+ name${ spaceIdsSelection }
124+ valuesList${ valuesListFilter } {
125+ propertyId
126+ text
127+ boolean
128+ float
129+ datetime
130+ point
131+ schedule
132+ }
133+ ${ level1Relations }
134+ }
98135}` ;
99136} ;
100137
0 commit comments