feat(search)!: resolve a reference across several targets - #848
Open
ddeboer wants to merge 3 commits into
Open
Conversation
A lookup’s target (and an idOnly’s labelSource) may name several Root Types, in order of precedence. Each referent resolves against every named collection and is read through the declaration of the one that holds it – label, key and facet policy per value – and a stored referent carries an rdf:type-derived discriminator so an unidentified one is still served as the kind it was stated to be. A GraphQL surface emits an interface named for the set, implemented by each target’s own reference type, so __typename is truthful per referent; the field’s filter is named for the set too. joinable is refused on such a lookup. BREAKING CHANGE: labelSourceNameOf, labelTargetNameOf, localLookupTypeOf and inheritedFacetKeys are replaced by labelSourceNamesOf, labelTargetNamesOf, localLookupTargetsOf and inheritedFacetPolicies, which return lists (or a map) rather than a single value; _target is a reserved field name.
- Drop the GraphQL fixture that named one field at two referents: the schema now rejects that pairing, so the interface builder no longer re-checks it and the branch threshold is re-anchored. - Cover a single-target lookup skipping an id-only selection, an empty stored referent field, a single-valued polymorphic nesting and a cut descent that still declares its discriminator.
…ocal lookup The empty-endpoint case is read one level in, by the stored lookup, not by the inline entry above it – so the test states an edge without a creator rather than a work without edges.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix #717
A
lookup’starget(and anidOnly’slabelSource) may now name several Root Types, in order of precedence, so a field whose referent may be aPersonor anOrganizationlabels every value, types every value truthfully, and serves each kind’s own fields.What changes
Declaration (
@lde/search)target: string | readonly string[],labelSourcelikewise; one plural reading (labelSourceNamesOf,labelTargetNamesOf,localLookupTargetsOf,referencedTargetsOf) replaces the single-target helpers, andinheritedFacetPoliciesreplacesinheritedFacetKeys.searchSchemarejects a target named twice,joinableon several targets, and two targets declaring one field differently (kind, arity, Roles, or a reference’s strategy/referent)._targetbecomes a reserved field name.Index time (
@lde/search,@lde/search-pipeline)rdf:type(oneOPTIONALtriple) and emits every target’s expansion or key hop.class, in declaration order, and treats the referent as a document of that target: re-keyed through its key, admitted to a facet by its policy. A stored (local) referent records the match under_target, so an unidentified referent is still served as the kind it was stated to be. Single-target lookups store exactly what they stored before.Query time (
@lde/search-typesense)NESTED_DOCUMENT_TYPE), never as a field.Surface (
@lde/search-api-graphql)PersonOrOrganizationReference, implemented by each‹Target›Referenceand carryingidplus every field the targets declare alike;__typenameresolves per referent, and an inline fragment reaches per-type fields.PersonOrOrganizationFilter { in: [IRI!] }; coarse discovery still finds it.Not in scope
A join predicate on a polymorphic reference (“works whose creator died before 1900”) stays out of reach – an engine reference names one collection – and is tracked in #845.
Records
ADR 27 amends ADR 21, which had rejected both a target list and an output-side interface on convenience grounds; a
__typenamethat is false for half the values is not a convenience problem. Thesearch,search-api-graphql,search-typesenseandsearch-pipelinereference pages describe the mechanism.BREAKING for schema-level readers only: the renamed helpers above. A declaration naming one target is unchanged in storage and in emitted GraphQL.