@lde/search-api-graphql 0.17.0 → 0.18.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.
@@ -1 +1 @@
1
- {"version":3,"file":"build-schema.d.ts","sourceRoot":"","sources":["../src/build-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,aAAa,EAQd,MAAM,SAAS,CAAC;AACjB,OAAO,EAIL,KAAK,YAAY,EAEjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAarB,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAGvB,8EAA8E;AAC9E,MAAM,WAAW,aAAa;IAC5B;;sDAEkD;IAClD,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,mFAAmF;IACnF,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,CAAC;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACjE;AAED;2EAC2E;AAC3E,MAAM,WAAW,iBAAiB;IAChC;yCACqC;IACrC,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;uBACmB;IACnB,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,aAAa,KACnB,WAAW,CAAC;CAClB;AAED,MAAM,WAAW,yBAAyB;IACxC;;kEAE8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC7D,+EAA+E;IAC/E,QAAQ,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;IACvC;;gDAE4C;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAkBD;;;;;;;;;GASG;AACH,wBA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,CAAC,EAAE,MAAM,CAAC;CAC9B;AAkBD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,yBAA8B,GACtC,aAAa,CAwbf;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAER"}
@@ -63,6 +63,20 @@ export function buildGraphQLSchema(schema, options = {}) {
63
63
  count: { type: new GraphQLNonNull(GraphQLInt) },
64
64
  },
65
65
  });
66
+ // A boolean-facet bucket: the value as a real boolean, so the bucket a client
67
+ // selects round-trips straight into the `is` filter that selects it. No label
68
+ // – a boolean has no data label to resolve, and the sensible rendering (“with
69
+ // an image” / “without one”) is knowable only by the consumer.
70
+ const booleanBucket = new GraphQLObjectType({
71
+ name: 'BooleanBucket',
72
+ fields: {
73
+ value: {
74
+ type: new GraphQLNonNull(GraphQLBoolean),
75
+ resolve: (bucket) => bucket.is,
76
+ },
77
+ count: { type: new GraphQLNonNull(GraphQLInt) },
78
+ },
79
+ });
66
80
  // The pagination actually applied (after queryDefaults), shared across every
67
81
  // ‹Type›SearchResult so one client pager fragment serves all root types.
68
82
  const paginationType = new GraphQLObjectType({
@@ -274,7 +288,8 @@ export function buildGraphQLSchema(schema, options = {}) {
274
288
  },
275
289
  });
276
290
  // Keyed facets object: one field per facetable field, typed by its kind
277
- // (range fields → [RangeBucket!], else [ValueBucket!]). Only the selected
291
+ // (range fields → [RangeBucket!], boolean fields → [BooleanBucket!], else
292
+ // [ValueBucket!]). Only the selected
278
293
  // fields are resolved (GraphQL prunes the rest), so the selection IS the
279
294
  // request; how they are computed – skip-own-filter, batched into one
280
295
  // engine dispatch – lives in facet-batch.ts.
@@ -329,6 +344,13 @@ export function buildGraphQLSchema(schema, options = {}) {
329
344
  },
330
345
  };
331
346
  }
347
+ /** The bucket type a facet’s kind earns: bins for a range facet, a real
348
+ * boolean for a boolean one, a keyed value otherwise. */
349
+ function bucketTypeFor(field) {
350
+ if (isRangeFacet(field))
351
+ return rangeBucket;
352
+ return field.kind === 'boolean' ? booleanBucket : valueBucket;
353
+ }
332
354
  /** The keyed facets object for one type (only called with ≥ 1 facetable field). */
333
355
  function facetsTypeFor(typeName, facetable) {
334
356
  return new GraphQLObjectType({
@@ -337,7 +359,7 @@ export function buildGraphQLSchema(schema, options = {}) {
337
359
  const fields = {};
338
360
  for (const field of facetable) {
339
361
  fields[field.name] = {
340
- type: nonNullListOf(isRangeFacet(field) ? rangeBucket : valueBucket),
362
+ type: nonNullListOf(bucketTypeFor(field)),
341
363
  // The skip-own-filter query building, the batching into one
342
364
  // engine dispatch and the degrade-to-[] error handling all live
343
365
  // in the loader (facet-batch.ts).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search-api-graphql",
3
- "version": "0.17.0",
3
+ "version": "0.18.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 – and serves it as a framework-agnostic fetch handler with a self-contained playground, SDL endpoint, CORS and depth/cost limits. 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",
@@ -28,7 +28,7 @@
28
28
  "@escape.tech/graphql-armor-cost-limit": "^2.4.3",
29
29
  "@escape.tech/graphql-armor-max-depth": "^2.4.2",
30
30
  "@graphql-yoga/render-graphiql": "^5.21.2",
31
- "@lde/search": "^0.16.0",
31
+ "@lde/search": "^0.17.0",
32
32
  "dataloader": "^2.2.3",
33
33
  "graphql": "^16.0.0",
34
34
  "graphql-yoga": "^5.21.2",