@lde/search-api-graphql 0.7.1 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -12
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,21 +3,21 @@
|
|
|
3
3
|
The GraphQL surface for the [`@lde/search`](../search) core. **Both engine- and
|
|
4
4
|
domain-agnostic:** it builds an executable
|
|
5
5
|
[graphql-js](https://graphql.org/graphql-js/) `GraphQLSchema` from your whole
|
|
6
|
-
[`SearchSchema`](../search/README.md#terminology) at runtime
|
|
6
|
+
[`SearchSchema`](../search/README.md#terminology) at runtime – one root query
|
|
7
7
|
field per `SearchType`, each searchable in its own way. All root fields are
|
|
8
8
|
served by the same resolver implementation (no per-type code, no codegen);
|
|
9
9
|
each root field gets its own instance of it, bound to that field’s
|
|
10
10
|
`SearchType`, over any `SearchEngine`. It names neither your **domain** (each type’s GraphQL name
|
|
11
|
-
is the `SearchType`’s own logical `name`
|
|
11
|
+
is the `SearchType`’s own logical `name` – `Dataset`, `Person`, `CreativeWork`,
|
|
12
12
|
…) nor your **engine** (the resolver calls the schema-bound `context.engine`, be it
|
|
13
13
|
[`@lde/search-typesense`](../search-typesense) or another adapter).
|
|
14
14
|
|
|
15
15
|
## Runtime configuration, not codegen
|
|
16
16
|
|
|
17
17
|
`buildGraphQLSchema(schema)` constructs the GraphQL schema once at startup from
|
|
18
|
-
the field model
|
|
18
|
+
the field model – no SDL artifact, no generated resolver stubs. For you that
|
|
19
19
|
means: no codegen step in the build, no generated files to commit and review,
|
|
20
|
-
and no stale artifact that can drift from the declaration
|
|
20
|
+
and no stale artifact that can drift from the declaration – change the
|
|
21
21
|
`SearchType`, restart, and the API is current. (The flip side, no artifact
|
|
22
22
|
showing contract changes as diffs, is restored by the
|
|
23
23
|
[snapshot guard](#guarding-the-contract).) The field model
|
|
@@ -63,14 +63,17 @@ types such as a common `Agent`) are created once and reused across root types.
|
|
|
63
63
|
|
|
64
64
|
`types` never filters: every `SearchType` in the schema you pass gets a root
|
|
65
65
|
field (options for a type not in the schema are a build-time error). To expose
|
|
66
|
-
only part of what you index, narrow the **schema argument**
|
|
67
|
-
(`searchSchema(…)` is a cheap constructor
|
|
66
|
+
only part of what you index, narrow the **schema argument** you hand
|
|
67
|
+
`buildGraphQLSchema` (`searchSchema(…)` is a cheap constructor, so build one per
|
|
68
|
+
consumer):
|
|
68
69
|
|
|
69
70
|
```ts
|
|
70
|
-
// Index
|
|
71
|
-
|
|
71
|
+
// Index a superset: hand a three-type schema to the pipeline, which projects and
|
|
72
|
+
// stores one collection per type (see @lde/search-pipeline). INTERNAL is indexed
|
|
73
|
+
// (e.g. a label source references resolve against) but never served.
|
|
74
|
+
const indexed = searchSchema(DATASET, PERSON, INTERNAL);
|
|
72
75
|
|
|
73
|
-
//
|
|
76
|
+
// Serve a subset: the GraphQL API exposes only two of those types.
|
|
74
77
|
const gqlSchema = buildGraphQLSchema(searchSchema(DATASET, PERSON));
|
|
75
78
|
```
|
|
76
79
|
|
|
@@ -98,7 +101,7 @@ const gqlSchema = buildGraphQLSchema(searchSchema(DATASET, PERSON));
|
|
|
98
101
|
## Guarding the contract
|
|
99
102
|
|
|
100
103
|
Why the API, the index and a future REST surface cannot drift apart is the
|
|
101
|
-
search family’s overall approach
|
|
104
|
+
search family’s overall approach – one field model, one query IR – described
|
|
102
105
|
in [`@lde/search`](../search/README.md). Specific to this surface: the GraphQL
|
|
103
106
|
contract is **frozen** (breaking to change), yet generated rather than
|
|
104
107
|
handwritten, so nothing in the repo shows a contract change as a reviewable
|
|
@@ -114,8 +117,8 @@ it('keeps the public GraphQL contract stable', () => {
|
|
|
114
117
|
```
|
|
115
118
|
|
|
116
119
|
The first run writes the emitted SDL to a committed snapshot file; every later
|
|
117
|
-
run re-emits and diffs against it. Any contract change
|
|
120
|
+
run re-emits and diffs against it. Any contract change – your own schema edit,
|
|
118
121
|
or a new version of this library emitting different GraphQL for the same
|
|
119
|
-
declaration
|
|
122
|
+
declaration – fails the test and shows the SDL diff, until you consciously
|
|
120
123
|
accept it (`vitest -u`) and the reviewer sees the contract change spelled out
|
|
121
124
|
in the PR.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-api-graphql",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Engine- and domain-agnostic GraphQL surface for @lde/search: builds an executable GraphQLSchema from a whole SearchSchema at runtime (no codegen) — one root query field per SearchType — served by generic resolvers over any SearchEngine. You supply the schema and per-type typeNames; it names neither your domain nor your engine.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"!**/*.tsbuildinfo"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lde/search": "^0.
|
|
28
|
+
"@lde/search": "^0.10.0",
|
|
29
29
|
"dataloader": "^2.2.3",
|
|
30
30
|
"graphql": "^15.8.0",
|
|
31
31
|
"tslib": "^2.3.0"
|