@stonecrop/graphql-middleware 0.24.0 → 0.25.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":"postgraphile.d.ts","sourceRoot":"","sources":["../../../src/plugin/postgraphile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAgB,WAAW,EAAiD,MAAM,mBAAmB,CAAA;AAGjH,OAAO,KAAK,EAAE,QAAQ,EAAc,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAW5D;;;;;;GAMG;AACH,MAAM,WAAW,oBAAoB;IACpC;;;;;;;;;;;;;;;;;;OAkBG;IACH,QAAQ,EAAE,QAAQ,CAAA;IAClB,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAA;IACf,iGAAiG;IACjG,MAAM,EAAE,MAAM,CAAA;IACd,yFAAyF;IACzF,IAAI,EAAE,WAAW,CAAA;IACjB,8GAA8G;IAC9G,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1B;;;;;;OAMG;IACH,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC7B,wFAAwF;IACxF,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,kGAAkG;IAClG,YAAY,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;;;;GAUG;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE/E;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,cAAc,CAAC,EAA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E;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAA;IACf;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoCG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC,CAAA;IAC9D;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC;AAmCD;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,GAAI,UAAS,sBAA2B,KAAG,cAAc,CAAC,MAwsB3F,CAAA;AA0BD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,CAQvD;AA6HD;;;;;GAKG"}
@@ -250,6 +250,15 @@ export const createStonecropPlugin = (options = {}) => {
250
250
  const backlinkCol = camelToSnake(link.backlink);
251
251
  let sql = `SELECT ${targetColumns} FROM ${resolveTableName(targetMeta.name, options.tables)} WHERE "${backlinkCol}"::text = $1`;
252
252
  const linkValues = [specId];
253
+ // Same reason the list path orders: a capped relation without a fixed order
254
+ // returns an arbitrary subset of the children, and a different one each time
255
+ // a child row is updated. `truncatedLinks` says the tail was cut; it cannot
256
+ // say the head kept changing. Skipped when the target declares no identity —
257
+ // there is no stable key to order by, and inventing one would be a guess.
258
+ const linkPkMeta = getPkMeta(targetMeta);
259
+ if (linkPkMeta) {
260
+ sql += ` ORDER BY "${camelToSnake(linkPkMeta.fieldname)}" ASC`;
261
+ }
253
262
  if (effectiveLimit != null) {
254
263
  // One row more than the cap, same probe the list path uses: its presence
255
264
  // is the whole truncation answer and costs no second query.
@@ -378,6 +387,22 @@ export const createStonecropPlugin = (options = {}) => {
378
387
  }
379
388
  orderByClause = ` ORDER BY "${camelToSnake(fieldName)}" ${dir}`;
380
389
  }
390
+ // A page is only meaningful against a fixed order, and LIMIT/OFFSET without one
391
+ // is two independent scans of heap order — an UPDATE between them moves that row
392
+ // to the tail, so the row it displaced is never returned and nothing in the
393
+ // payload says a record was skipped. The declared identity is the right default
394
+ // because it is unique: it gives a total order, which is what makes page 2 start
395
+ // exactly where page 1 stopped.
396
+ //
397
+ // Only when the doctype declares an identity. Without one there is no stable key
398
+ // to order by, and inventing one here would be a guess; such a doctype cannot be
399
+ // paged stably by any means.
400
+ if (orderByClause === '') {
401
+ const listPkMeta = getPkMeta(meta);
402
+ if (listPkMeta) {
403
+ orderByClause = ` ORDER BY "${camelToSnake(listPkMeta.fieldname)}" ASC`;
404
+ }
405
+ }
381
406
  // LIMIT / OFFSET. A caller that names no limit gets the configured default rather
382
407
  // than the whole table: omission is how an unbounded scan used to happen, and the
383
408
  // only guard against it lived in the scaffold's fetch helper, which is neither the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stonecrop/graphql-middleware",
3
- "version": "0.24.0",
3
+ "version": "0.25.0",
4
4
  "description": "GraphQL middleware for PostGraphile and Stonecrop schema",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "graphql": "^16.14.0",
24
24
  "pluralize": "^8.0.0",
25
25
  "postgraphile": "^5.0.3",
26
- "@stonecrop/schema": "0.24.0"
26
+ "@stonecrop/schema": "0.25.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@electric-sql/pglite": "^0.4.5",