graphile-i18n 2.14.3 → 2.15.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/esm/plugin.js +6 -2
- package/package.json +6 -5
- package/plugin.js +6 -2
package/esm/plugin.js
CHANGED
|
@@ -20,6 +20,7 @@ import 'graphile-build';
|
|
|
20
20
|
import 'graphile-build-pg';
|
|
21
21
|
import { TYPES } from '@dataplan/pg';
|
|
22
22
|
import { context as grafastContext, lambda, object } from 'grafast';
|
|
23
|
+
import { withSystemLaneClient } from 'graphile-plugin-utils';
|
|
23
24
|
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
24
25
|
function hasI18nTag(codec) {
|
|
25
26
|
const tags = codec.extensions?.tags;
|
|
@@ -256,8 +257,11 @@ export function createI18nPlugin(options = {}) {
|
|
|
256
257
|
}
|
|
257
258
|
return result;
|
|
258
259
|
}
|
|
259
|
-
|
|
260
|
-
|
|
260
|
+
// Translation lookup is a server-side read, so it runs in the
|
|
261
|
+
// system lane's bounded role inside one transaction rather
|
|
262
|
+
// than inheriting the pool's connecting role.
|
|
263
|
+
const row = await withSystemLaneClient(withPgClient, async (client) => {
|
|
264
|
+
const { rows } = await client.query({ text: sqlQuery, values: [id, langs] });
|
|
261
265
|
return rows[0] ?? null;
|
|
262
266
|
});
|
|
263
267
|
if (!row) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-i18n",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.15.0",
|
|
4
4
|
"description": "PostGraphile v5 i18n plugin — language-aware fields from @i18n translation tables with Accept-Language negotiation and fallback chains",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/constructive-io/constructive",
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"url": "https://github.com/constructive-io/constructive/issues"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"accept-language-parser": "^1.5.0"
|
|
32
|
+
"accept-language-parser": "^1.5.0",
|
|
33
|
+
"graphile-plugin-utils": "^1.12.2"
|
|
33
34
|
},
|
|
34
35
|
"peerDependencies": {
|
|
35
36
|
"@dataplan/pg": "^1.1.1",
|
|
@@ -45,10 +46,10 @@
|
|
|
45
46
|
"@types/accept-language-parser": "^1.5.4",
|
|
46
47
|
"@types/node": "^22.19.11",
|
|
47
48
|
"@types/pg": "^8.20.4",
|
|
48
|
-
"graphile-test": "^5.14.
|
|
49
|
+
"graphile-test": "^5.14.5",
|
|
49
50
|
"makage": "^0.8.0",
|
|
50
51
|
"pg": "^8.21.0",
|
|
51
|
-
"pgsql-test": "^5.13.
|
|
52
|
+
"pgsql-test": "^5.13.5"
|
|
52
53
|
},
|
|
53
54
|
"keywords": [
|
|
54
55
|
"postgraphile",
|
|
@@ -63,5 +64,5 @@
|
|
|
63
64
|
"accept-language",
|
|
64
65
|
"locale"
|
|
65
66
|
],
|
|
66
|
-
"gitHead": "
|
|
67
|
+
"gitHead": "01e073830677c0587bab564b7d575a06b5156f0c"
|
|
67
68
|
}
|
package/plugin.js
CHANGED
|
@@ -24,6 +24,7 @@ require("graphile-build");
|
|
|
24
24
|
require("graphile-build-pg");
|
|
25
25
|
const pg_1 = require("@dataplan/pg");
|
|
26
26
|
const grafast_1 = require("grafast");
|
|
27
|
+
const graphile_plugin_utils_1 = require("graphile-plugin-utils");
|
|
27
28
|
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
28
29
|
function hasI18nTag(codec) {
|
|
29
30
|
const tags = codec.extensions?.tags;
|
|
@@ -260,8 +261,11 @@ function createI18nPlugin(options = {}) {
|
|
|
260
261
|
}
|
|
261
262
|
return result;
|
|
262
263
|
}
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
// Translation lookup is a server-side read, so it runs in the
|
|
265
|
+
// system lane's bounded role inside one transaction rather
|
|
266
|
+
// than inheriting the pool's connecting role.
|
|
267
|
+
const row = await (0, graphile_plugin_utils_1.withSystemLaneClient)(withPgClient, async (client) => {
|
|
268
|
+
const { rows } = await client.query({ text: sqlQuery, values: [id, langs] });
|
|
265
269
|
return rows[0] ?? null;
|
|
266
270
|
});
|
|
267
271
|
if (!row) {
|