feat(search): let a search type name its label field - #729
Merged
Conversation
- add `SearchTypeBase.labelField`, defaulting to `label`, so the word a label source serves its display field under is the profile's, not one an internal role imposes - resolve the label field through `labelFieldNameOf`; the validation message quotes the configured name - key a GraphQL reference object's label off its label source's configured name, leaving `ValueBucket.label` per-facet-field - document the option in the search reference, and amend ADR 4 and ADR 8
The earlier tests in the file load the real Prettier, so the mock only took effect where the module graph happened to be re-evaluated – green locally, red on CI. Reset and re-import the module under test instead.
…disagreeing label words One emitted reference type cannot serve two words, and the memoisation by `ref.typeName` would otherwise let declaration order decide which field's label source wins. Also record why a label source is always a Root Type, and drop a stale sentence the new docs section contradicted.
This was referenced Aug 14, 2026
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.
A type serving as a
labelSourcehad to declare its display field with theliteral name
label, so the word the API serves was decided by an internal rolerather than by the profile the schema declares to. In SCHEMA-AP-NDE,
Person,Organization,PlaceandDefinedTermall carryschema:name, and consumersexpect
name– but only a type nothing resolves labels from could serve it.A type can now name its own label field:
Changes
@lde/search:SearchTypeBasegainslabelField;labelFieldOfresolves itthrough the new
labelFieldNameOf(withDEFAULT_LABEL_FIELD), and theschema-wide validation message quotes the configured name. Both helpers are
exported from the adapter surface.
@lde/search-api-graphql: a reference object type keys its resolved label offthe label source’s configured name, so
TermReferencebecomes{ id, name }.ValueBucket.labelis unchanged – it is per-facet-field, and a per-type namewould make the bucket type non-uniform.
buildGraphQLSchemanow rejects fields that share a
ref.typeNamebut resolve labels from sourcesdisagreeing on their
labelField– otherwise declaration order would silentlydecide which word both fields serve.
@lde/search-typesenseneeds no change: it already resolves the field throughlabelFieldOf. The engine-port propertylabelalso stays – it is a wirename, not a served one.
to the GraphQL and Typesense references,
packages/search/CONTEXT.md, andamendments to ADR 4 and ADR 8.
Non-breaking – every existing schema keeps the default.
Also fixes an unrelated test that this branch happens to make CI run: the
Prettier-peer case in
print-sdl.test.tsmocked a module the earlier tests hadalready loaded, so it passed locally and failed on CI. It now resets the module
graph and re-imports the module under test.
Fix #727