@constructive-io/graphql-server 4.12.0 → 4.13.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.
|
@@ -3,7 +3,7 @@ import { getNodeEnv } from '@pgpmjs/env';
|
|
|
3
3
|
import { Logger } from '@pgpmjs/logger';
|
|
4
4
|
import { createGraphileInstance, graphileCache } from 'graphile-cache';
|
|
5
5
|
import { ConstructivePreset, makePgService } from 'graphile-settings';
|
|
6
|
-
import {
|
|
6
|
+
import { getPgPool } from 'pg-cache';
|
|
7
7
|
import { getPgEnvOptions } from 'pg-env';
|
|
8
8
|
import './types'; // for Request type
|
|
9
9
|
import { isGraphqlObservabilityEnabled } from '../diagnostics/observability';
|
|
@@ -109,12 +109,12 @@ const reqLabel = (req) => (req.requestId ? `[${req.requestId}]` : '[req]');
|
|
|
109
109
|
/**
|
|
110
110
|
* Build a PostGraphile v5 preset for a tenant.
|
|
111
111
|
*/
|
|
112
|
-
const buildPreset = (
|
|
112
|
+
const buildPreset = (pool, schemas, anonRole, roleName) => {
|
|
113
113
|
return {
|
|
114
114
|
extends: [ConstructivePreset],
|
|
115
115
|
pgServices: [
|
|
116
116
|
makePgService({
|
|
117
|
-
|
|
117
|
+
pool,
|
|
118
118
|
schemas,
|
|
119
119
|
}),
|
|
120
120
|
],
|
|
@@ -227,9 +227,11 @@ export const graphile = (opts) => {
|
|
|
227
227
|
...opts.pg,
|
|
228
228
|
database: dbname,
|
|
229
229
|
});
|
|
230
|
-
|
|
230
|
+
// Route through pg-cache so the pool is tracked and can be cleaned up
|
|
231
|
+
// properly, preventing leaked connections during database teardown.
|
|
232
|
+
const pool = getPgPool(pgConfig);
|
|
231
233
|
// Create promise and store in in-flight map BEFORE try block
|
|
232
|
-
const preset = buildPreset(
|
|
234
|
+
const preset = buildPreset(pool, schema || [], anonRole, roleName);
|
|
233
235
|
const creationPromise = observeGraphileBuild({
|
|
234
236
|
cacheKey: key,
|
|
235
237
|
serviceKey: key,
|
package/middleware/graphile.js
CHANGED
|
@@ -118,12 +118,12 @@ const reqLabel = (req) => (req.requestId ? `[${req.requestId}]` : '[req]');
|
|
|
118
118
|
/**
|
|
119
119
|
* Build a PostGraphile v5 preset for a tenant.
|
|
120
120
|
*/
|
|
121
|
-
const buildPreset = (
|
|
121
|
+
const buildPreset = (pool, schemas, anonRole, roleName) => {
|
|
122
122
|
return {
|
|
123
123
|
extends: [graphile_settings_1.ConstructivePreset],
|
|
124
124
|
pgServices: [
|
|
125
125
|
(0, graphile_settings_1.makePgService)({
|
|
126
|
-
|
|
126
|
+
pool,
|
|
127
127
|
schemas,
|
|
128
128
|
}),
|
|
129
129
|
],
|
|
@@ -236,9 +236,11 @@ const graphile = (opts) => {
|
|
|
236
236
|
...opts.pg,
|
|
237
237
|
database: dbname,
|
|
238
238
|
});
|
|
239
|
-
|
|
239
|
+
// Route through pg-cache so the pool is tracked and can be cleaned up
|
|
240
|
+
// properly, preventing leaked connections during database teardown.
|
|
241
|
+
const pool = (0, pg_cache_1.getPgPool)(pgConfig);
|
|
240
242
|
// Create promise and store in in-flight map BEFORE try block
|
|
241
|
-
const preset = buildPreset(
|
|
243
|
+
const preset = buildPreset(pool, schema || [], anonRole, roleName);
|
|
242
244
|
const creationPromise = (0, graphile_build_stats_1.observeGraphileBuild)({
|
|
243
245
|
cacheKey: key,
|
|
244
246
|
serviceKey: key,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-server",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Constructive GraphQL Server",
|
|
6
6
|
"main": "index.js",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"graphile-build-pg": "5.0.0-rc.8",
|
|
64
64
|
"graphile-cache": "^3.3.4",
|
|
65
65
|
"graphile-config": "1.0.0-rc.6",
|
|
66
|
-
"graphile-settings": "^4.
|
|
66
|
+
"graphile-settings": "^4.12.0",
|
|
67
67
|
"graphile-utils": "5.0.0-rc.8",
|
|
68
68
|
"graphql": "16.13.0",
|
|
69
69
|
"graphql-upload": "^13.0.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"nodemon": "^3.1.14",
|
|
92
92
|
"ts-node": "^10.9.2"
|
|
93
93
|
},
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "b8d4ae2b36e37e7f3533f858f19ec000febaa04b"
|
|
95
95
|
}
|