Skip to content

Commit 9c32282

Browse files
Add AbstractTypeFilter query adapter for index inheritance (#1163)
* Add AbstractTypeFilter query adapter for index inheritance When abstract types share an index with unrelated concrete types via index inheritance, a query for the abstract type would otherwise return documents belonging to those other types. AbstractTypeFilter is a new query adapter that prevents this by automatically injecting an internal __typename filter scoped to the queried type's concrete subtypes. Also fixes requested_fields to use unwrap_fully before checking abstract?, which ensures __typename is fetched for abstract types returned via the nodes relay connection field (where the field type is list-wrapped, e.g. [Store!]!). End-to-end acceptance tests covering index inheritance query behavior are coming in a follow-up PR; this branch intentionally keeps coverage to minimal unit tests to reduce the set of reviewable changes. * Address PR 1163 review feedback on AbstractTypeFilter - Rename `concrete_non_subtypes_in_shared_index` → `shares_index_with_non_subtypes?` (boolean) - Add nil optimization: only include nil in `__typename` values when a queried index stores a single type - Replace `ThirdPartyWholesale` with `Wholesale` sub-interface in the stock schema to enable a test for the nil-omitted case * More fixes based on review feedback * Fix search_index_definitions for abstract types to exclude declared index when overridden Abstract types derive their search index set purely from their concrete subtypes. This avoids unnecessarily searching a shared index when all concrete subtypes have overridden it with dedicated indexes. Generated with Claude Code
1 parent 770801b commit 9c32282

22 files changed

Lines changed: 1440 additions & 187 deletions

File tree

config/schema/artifacts/json_schemas.yaml

Lines changed: 38 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ json_schema_version: 1
2323
type: string
2424
enum:
2525
- Address
26+
- BrokerWholesaler
2627
- Company
2728
- Component
29+
- DirectWholesaler
2830
- ElectricalPart
2931
- Manufacturer
3032
- MechanicalPart
@@ -33,7 +35,6 @@ json_schema_version: 1
3335
- PhysicalStore
3436
- Sponsor
3537
- Team
36-
- ThirdPartyWholesale
3738
- Widget
3839
- WidgetWorkspace
3940
id:
@@ -160,6 +161,24 @@ json_schema_version: 1
160161
- sponsorships_object
161162
Boolean:
162163
type: boolean
164+
BrokerWholesaler:
165+
type: object
166+
properties:
167+
id:
168+
allOf:
169+
- "$ref": "#/$defs/ID"
170+
- maxLength: 8191
171+
active:
172+
anyOf:
173+
- "$ref": "#/$defs/Boolean"
174+
- type: 'null'
175+
__typename:
176+
type: string
177+
const: BrokerWholesaler
178+
default: BrokerWholesaler
179+
required:
180+
- id
181+
- active
163182
Color:
164183
type: string
165184
enum:
@@ -253,6 +272,24 @@ json_schema_version: 1
253272
DateTime:
254273
type: string
255274
format: date-time
275+
DirectWholesaler:
276+
type: object
277+
properties:
278+
id:
279+
allOf:
280+
- "$ref": "#/$defs/ID"
281+
- maxLength: 8191
282+
active:
283+
anyOf:
284+
- "$ref": "#/$defs/Boolean"
285+
- type: 'null'
286+
__typename:
287+
type: string
288+
const: DirectWholesaler
289+
default: DirectWholesaler
290+
required:
291+
- id
292+
- active
256293
ElectricalPart:
257294
type: object
258295
properties:
@@ -875,24 +912,6 @@ json_schema_version: 1
875912
- was_shortened
876913
- players_nested
877914
- players_object
878-
ThirdPartyWholesale:
879-
type: object
880-
properties:
881-
id:
882-
allOf:
883-
- "$ref": "#/$defs/ID"
884-
- maxLength: 8191
885-
active:
886-
anyOf:
887-
- "$ref": "#/$defs/Boolean"
888-
- type: 'null'
889-
__typename:
890-
type: string
891-
const: ThirdPartyWholesale
892-
default: ThirdPartyWholesale
893-
required:
894-
- id
895-
- active
896915
Untyped:
897916
type:
898917
- array

config/schema/artifacts/json_schemas_by_version/v1.yaml

Lines changed: 50 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ json_schema_version: 1
2323
type: string
2424
enum:
2525
- Address
26+
- BrokerWholesaler
2627
- Company
2728
- Component
29+
- DirectWholesaler
2830
- ElectricalPart
2931
- Manufacturer
3032
- MechanicalPart
@@ -33,7 +35,6 @@ json_schema_version: 1
3335
- PhysicalStore
3436
- Sponsor
3537
- Team
36-
- ThirdPartyWholesale
3738
- Widget
3839
- WidgetWorkspace
3940
id:
@@ -187,6 +188,30 @@ json_schema_version: 1
187188
- sponsorships_object
188189
Boolean:
189190
type: boolean
191+
BrokerWholesaler:
192+
type: object
193+
properties:
194+
id:
195+
allOf:
196+
- "$ref": "#/$defs/ID"
197+
- maxLength: 8191
198+
ElasticGraph:
199+
type: ID!
200+
nameInIndex: id
201+
active:
202+
anyOf:
203+
- "$ref": "#/$defs/Boolean"
204+
- type: 'null'
205+
ElasticGraph:
206+
type: Boolean
207+
nameInIndex: active
208+
__typename:
209+
type: string
210+
const: BrokerWholesaler
211+
default: BrokerWholesaler
212+
required:
213+
- id
214+
- active
190215
Color:
191216
type: string
192217
enum:
@@ -313,6 +338,30 @@ json_schema_version: 1
313338
DateTime:
314339
type: string
315340
format: date-time
341+
DirectWholesaler:
342+
type: object
343+
properties:
344+
id:
345+
allOf:
346+
- "$ref": "#/$defs/ID"
347+
- maxLength: 8191
348+
ElasticGraph:
349+
type: ID!
350+
nameInIndex: id
351+
active:
352+
anyOf:
353+
- "$ref": "#/$defs/Boolean"
354+
- type: 'null'
355+
ElasticGraph:
356+
type: Boolean
357+
nameInIndex: active
358+
__typename:
359+
type: string
360+
const: DirectWholesaler
361+
default: DirectWholesaler
362+
required:
363+
- id
364+
- active
316365
ElectricalPart:
317366
type: object
318367
properties:
@@ -1175,30 +1224,6 @@ json_schema_version: 1
11751224
- was_shortened
11761225
- players_nested
11771226
- players_object
1178-
ThirdPartyWholesale:
1179-
type: object
1180-
properties:
1181-
id:
1182-
allOf:
1183-
- "$ref": "#/$defs/ID"
1184-
- maxLength: 8191
1185-
ElasticGraph:
1186-
type: ID!
1187-
nameInIndex: id
1188-
active:
1189-
anyOf:
1190-
- "$ref": "#/$defs/Boolean"
1191-
- type: 'null'
1192-
ElasticGraph:
1193-
type: Boolean
1194-
nameInIndex: active
1195-
__typename:
1196-
type: string
1197-
const: ThirdPartyWholesale
1198-
default: ThirdPartyWholesale
1199-
required:
1200-
- id
1201-
- active
12021227
Untyped:
12031228
type:
12041229
- array

0 commit comments

Comments
 (0)