@lde/search-api-graphql 0.28.0 → 0.29.1

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,EAWL,aAAa,EAQd,MAAM,SAAS,CAAC;AACjB,OAAO,EAKL,KAAK,YAAY,EAIjB,KAAK,WAAW,EAChB,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAsBrB,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,eAAe,CAAC;AAIvB,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;AA4GD;;;;;;;;;GASG;AACH,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AC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AA4GD;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,yBAA8B,GACtC,aAAa,CAw6Bf;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,yBAA8B,GACtC,MAAM,CAER"}
@@ -342,9 +342,10 @@ export function buildGraphQLSchema(schema, options = {}) {
342
342
  * referenced shape. A **surfaced inline** reference is served as the nested
343
343
  * object its Reference Type declares – its own `output` fields, configured by
344
344
  * exactly the same per-kind rules a root type’s fields are – so the response
345
- * shape matches the data’s shape. Its `id` is nullable: a referent needs no
346
- * identity, and a blank-node one nests without one. Every other reference
347
- * stays the id-plus-label pair its strategy carries.
345
+ * shape matches the data’s shape. It offers no `id`: a referent needs no
346
+ * identity, so the projection stores none, and its `output` fields are all a
347
+ * client can select. Every other reference stays the id-plus-label pair its
348
+ * strategy carries.
348
349
  */
349
350
  function registerReferenceType(field, owner) {
350
351
  if (field.kind !== 'reference' ||
@@ -383,27 +384,35 @@ export function buildGraphQLSchema(schema, options = {}) {
383
384
  const nested = (field.ref.strategy === 'lookup'
384
385
  ? rootTypesByName.get(field.ref.target)
385
386
  : nestedReferenceType(schema, field));
387
+ // An inline entry carries no `id`, so its output fields are all a client
388
+ // can select; GraphQL refuses an object type with none.
389
+ if (nested.class === undefined && outputFields(nested).length === 0) {
390
+ throw new Error(`Inline reference “${owner.name}.${field.name}” is \`output\`, but its reference type “${typeName}” declares no \`output\` field, so the API has nothing to serve for an entry; mark a field of “${typeName}” \`output\`, or drop \`output\` from the reference.`);
391
+ }
386
392
  referenceTypes.set(typeName, new GraphQLObjectType({
387
393
  name: graphQLName,
388
394
  // A thunk, so a Reference Type nesting another one resolves whatever
389
395
  // the registration order is (the graph is acyclic by searchSchema).
390
396
  fields: () => ({
391
397
  // A lookup resolves a document by IRI, so its `id` is always there.
392
- // An inline referent’s is nullable, and load-bearing: a referent
393
- // needs no identity, so a blank-node one nests exactly like a named
394
- // one, minus this.
398
+ // An inline referent has none: an entry of a Reference Type is read,
399
+ // not addressed, so the projection carries no `id` past its own
400
+ // derives, and a field that is never filled is not offered.
395
401
  //
396
- // A `local` lookup is the exception among lookups, for that same
402
+ // A `local` lookup is the exception among lookups, for a related
397
403
  // reason: it stores what the referring document says about the
398
404
  // endpoint whether or not the endpoint is identified, so an entry
399
405
  // may legitimately arrive without one. Declared non-null, every such
400
406
  // entry would fail the response instead of serving what it has.
401
- id: {
402
- type: field.ref?.strategy === 'lookup' &&
403
- !nullableIdTargets.has(typeName)
404
- ? new GraphQLNonNull(iriScalar)
405
- : iriScalar,
406
- },
407
+ ...(nested.class === undefined
408
+ ? {}
409
+ : {
410
+ id: {
411
+ type: nullableIdTargets.has(typeName)
412
+ ? iriScalar
413
+ : new GraphQLNonNull(iriScalar),
414
+ },
415
+ }),
407
416
  ...Object.fromEntries(outputFields(nested).map((nestedField) => [
408
417
  nestedField.name,
409
418
  // `required` is relaxed for the same reason `id` is above: a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search-api-graphql",
3
- "version": "0.28.0",
3
+ "version": "0.29.1",
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",
@@ -36,13 +36,13 @@
36
36
  "dependencies": {
37
37
  "@escape.tech/graphql-armor-cost-limit": "^2.4.3",
38
38
  "@escape.tech/graphql-armor-max-depth": "^2.4.2",
39
- "@graphql-yoga/render-graphiql": "^5.21.3",
40
- "@lde/search": "^0.26.0",
39
+ "@graphql-yoga/render-graphiql": "^5.24.2",
40
+ "@lde/search": "^0.27.1",
41
41
  "commander": "^15.0.0",
42
42
  "dataloader": "^2.2.3",
43
43
  "graphql": "^16.9.0",
44
- "graphql-yoga": "^5.21.3",
45
- "negotiator": "^1.0.0",
44
+ "graphql-yoga": "^5.24.1",
45
+ "negotiator": "^1.1.0",
46
46
  "tslib": "^2.3.0"
47
47
  },
48
48
  "peerDependencies": {