Commit 9c32282
authored
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 Code1 parent 770801b commit 9c32282
22 files changed
Lines changed: 1440 additions & 187 deletions
File tree
- config/schema
- artifacts_with_apollo
- json_schemas_by_version
- artifacts
- json_schemas_by_version
- elasticgraph-graphql
- lib/elastic_graph
- graphql
- query_adapter
- resolvers
- schema
- sig/elastic_graph/graphql
- query_adapter
- schema
- spec
- acceptance
- unit/elastic_graph/graphql
- query_adapter
- schema
- spec_support/lib/elastic_graph/spec_support/factories
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
160 | 161 | | |
161 | 162 | | |
162 | 163 | | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
163 | 182 | | |
164 | 183 | | |
165 | 184 | | |
| |||
253 | 272 | | |
254 | 273 | | |
255 | 274 | | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
256 | 293 | | |
257 | 294 | | |
258 | 295 | | |
| |||
875 | 912 | | |
876 | 913 | | |
877 | 914 | | |
878 | | - | |
879 | | - | |
880 | | - | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
885 | | - | |
886 | | - | |
887 | | - | |
888 | | - | |
889 | | - | |
890 | | - | |
891 | | - | |
892 | | - | |
893 | | - | |
894 | | - | |
895 | | - | |
896 | 915 | | |
897 | 916 | | |
898 | 917 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| |||
33 | 35 | | |
34 | 36 | | |
35 | 37 | | |
36 | | - | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
187 | 188 | | |
188 | 189 | | |
189 | 190 | | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
190 | 215 | | |
191 | 216 | | |
192 | 217 | | |
| |||
313 | 338 | | |
314 | 339 | | |
315 | 340 | | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
316 | 365 | | |
317 | 366 | | |
318 | 367 | | |
| |||
1175 | 1224 | | |
1176 | 1225 | | |
1177 | 1226 | | |
1178 | | - | |
1179 | | - | |
1180 | | - | |
1181 | | - | |
1182 | | - | |
1183 | | - | |
1184 | | - | |
1185 | | - | |
1186 | | - | |
1187 | | - | |
1188 | | - | |
1189 | | - | |
1190 | | - | |
1191 | | - | |
1192 | | - | |
1193 | | - | |
1194 | | - | |
1195 | | - | |
1196 | | - | |
1197 | | - | |
1198 | | - | |
1199 | | - | |
1200 | | - | |
1201 | | - | |
1202 | 1227 | | |
1203 | 1228 | | |
1204 | 1229 | | |
| |||
0 commit comments