@constructive-io/graphql-server 5.14.5 → 5.14.6
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/middleware/graphile.js +11 -6
- package/middleware/graphile.js +10 -5
- package/package.json +6 -6
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import './types'; // for Request type
|
|
2
2
|
import crypto from 'node:crypto';
|
|
3
|
-
import { classify, parse } from '@constructive-io/errors';
|
|
3
|
+
import { classify, errors, parse } from '@constructive-io/errors';
|
|
4
4
|
import { getNodeEnv } from '@pgpmjs/env';
|
|
5
5
|
import { Logger } from '@pgpmjs/logger';
|
|
6
6
|
import { createGraphileInstance, graphileCache } from 'graphile-cache';
|
|
@@ -10,9 +10,11 @@ import { getPgPool } from 'pg-cache';
|
|
|
10
10
|
import { getPgEnvOptions } from 'pg-env';
|
|
11
11
|
import { isGraphqlObservabilityEnabled } from '../diagnostics/observability';
|
|
12
12
|
import { HandlerCreationError } from '../errors/api-errors';
|
|
13
|
+
import { respondWithGraphQLError } from '../errors/graphql-response';
|
|
13
14
|
import { AuthCookiePlugin } from '../plugins/auth-cookie-plugin';
|
|
14
15
|
import { observeGraphileBuild } from './observability/graphile-build-stats';
|
|
15
16
|
const maskErrorLog = new Logger('graphile:maskError');
|
|
17
|
+
const isDev = () => getNodeEnv() === 'development';
|
|
16
18
|
/**
|
|
17
19
|
* GraphQL framework protocol codes. These originate in the GraphQL/grafast
|
|
18
20
|
* transport layer (not in constructive-db), so they are not Constructive domain
|
|
@@ -276,12 +278,14 @@ export const graphile = (opts) => {
|
|
|
276
278
|
const api = req.api;
|
|
277
279
|
if (!api) {
|
|
278
280
|
log.error(`${label} Missing API info`);
|
|
279
|
-
|
|
281
|
+
respondWithGraphQLError(res, errors.INTERNAL_FAILURE({ details: 'Missing API info' }));
|
|
282
|
+
return;
|
|
280
283
|
}
|
|
281
284
|
const key = req.svc_key;
|
|
282
285
|
if (!key) {
|
|
283
286
|
log.error(`${label} Missing service cache key`);
|
|
284
|
-
|
|
287
|
+
respondWithGraphQLError(res, errors.INTERNAL_FAILURE({ details: 'Missing service cache key' }));
|
|
288
|
+
return;
|
|
285
289
|
}
|
|
286
290
|
const { dbname, anonRole, roleName, schema } = api;
|
|
287
291
|
const schemaLabel = schema?.join(',') || 'unknown';
|
|
@@ -367,9 +371,10 @@ export const graphile = (opts) => {
|
|
|
367
371
|
catch (e) {
|
|
368
372
|
log.error(`${label} PostGraphile middleware error`, e);
|
|
369
373
|
if (!res.headersSent) {
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
});
|
|
374
|
+
respondWithGraphQLError(res, errors.INTERNAL_FAILURE({
|
|
375
|
+
details: isDev() ? e?.message ?? String(e) : 'An unexpected error occurred'
|
|
376
|
+
}));
|
|
377
|
+
return;
|
|
373
378
|
}
|
|
374
379
|
next(e);
|
|
375
380
|
}
|
package/middleware/graphile.js
CHANGED
|
@@ -19,9 +19,11 @@ const pg_cache_1 = require("pg-cache");
|
|
|
19
19
|
const pg_env_1 = require("pg-env");
|
|
20
20
|
const observability_1 = require("../diagnostics/observability");
|
|
21
21
|
const api_errors_1 = require("../errors/api-errors");
|
|
22
|
+
const graphql_response_1 = require("../errors/graphql-response");
|
|
22
23
|
const auth_cookie_plugin_1 = require("../plugins/auth-cookie-plugin");
|
|
23
24
|
const graphile_build_stats_1 = require("./observability/graphile-build-stats");
|
|
24
25
|
const maskErrorLog = new logger_1.Logger('graphile:maskError');
|
|
26
|
+
const isDev = () => (0, env_1.getNodeEnv)() === 'development';
|
|
25
27
|
/**
|
|
26
28
|
* GraphQL framework protocol codes. These originate in the GraphQL/grafast
|
|
27
29
|
* transport layer (not in constructive-db), so they are not Constructive domain
|
|
@@ -285,12 +287,14 @@ const graphile = (opts) => {
|
|
|
285
287
|
const api = req.api;
|
|
286
288
|
if (!api) {
|
|
287
289
|
log.error(`${label} Missing API info`);
|
|
288
|
-
|
|
290
|
+
(0, graphql_response_1.respondWithGraphQLError)(res, errors_1.errors.INTERNAL_FAILURE({ details: 'Missing API info' }));
|
|
291
|
+
return;
|
|
289
292
|
}
|
|
290
293
|
const key = req.svc_key;
|
|
291
294
|
if (!key) {
|
|
292
295
|
log.error(`${label} Missing service cache key`);
|
|
293
|
-
|
|
296
|
+
(0, graphql_response_1.respondWithGraphQLError)(res, errors_1.errors.INTERNAL_FAILURE({ details: 'Missing service cache key' }));
|
|
297
|
+
return;
|
|
294
298
|
}
|
|
295
299
|
const { dbname, anonRole, roleName, schema } = api;
|
|
296
300
|
const schemaLabel = schema?.join(',') || 'unknown';
|
|
@@ -376,9 +380,10 @@ const graphile = (opts) => {
|
|
|
376
380
|
catch (e) {
|
|
377
381
|
log.error(`${label} PostGraphile middleware error`, e);
|
|
378
382
|
if (!res.headersSent) {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
});
|
|
383
|
+
(0, graphql_response_1.respondWithGraphQLError)(res, errors_1.errors.INTERNAL_FAILURE({
|
|
384
|
+
details: isDev() ? e?.message ?? String(e) : 'An unexpected error occurred'
|
|
385
|
+
}));
|
|
386
|
+
return;
|
|
382
387
|
}
|
|
383
388
|
next(e);
|
|
384
389
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-server",
|
|
3
|
-
"version": "5.14.
|
|
3
|
+
"version": "5.14.6",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Constructive GraphQL Server",
|
|
6
6
|
"main": "index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"@constructive-io/express-context": "^0.23.2",
|
|
47
47
|
"@constructive-io/graphql-env": "^3.28.2",
|
|
48
48
|
"@constructive-io/graphql-types": "^3.27.2",
|
|
49
|
-
"@constructive-io/query-builder": "^3.9.
|
|
49
|
+
"@constructive-io/query-builder": "^3.9.4",
|
|
50
50
|
"@constructive-io/s3-utils": "^2.29.2",
|
|
51
51
|
"@constructive-io/url-domains": "^2.28.2",
|
|
52
52
|
"@graphile-contrib/pg-many-to-many": "2.0.0-rc.2",
|
|
@@ -65,8 +65,8 @@
|
|
|
65
65
|
"graphile-build-pg": "5.0.2",
|
|
66
66
|
"graphile-cache": "^4.9.2",
|
|
67
67
|
"graphile-config": "1.0.1",
|
|
68
|
-
"graphile-function-bindings": "^1.10.
|
|
69
|
-
"graphile-settings": "^6.11.
|
|
68
|
+
"graphile-function-bindings": "^1.10.6",
|
|
69
|
+
"graphile-settings": "^6.11.6",
|
|
70
70
|
"graphile-utils": "5.0.1",
|
|
71
71
|
"graphql": "16.13.0",
|
|
72
72
|
"graphql-upload": "^13.0.0",
|
|
@@ -88,10 +88,10 @@
|
|
|
88
88
|
"@types/pg": "^8.20.0",
|
|
89
89
|
"@types/request-ip": "^0.0.41",
|
|
90
90
|
"cookie-parser": "^1.4.7",
|
|
91
|
-
"graphile-test": "5.10.
|
|
91
|
+
"graphile-test": "5.10.6",
|
|
92
92
|
"makage": "^0.3.0",
|
|
93
93
|
"nodemon": "^3.1.14",
|
|
94
94
|
"ts-node": "^10.9.2"
|
|
95
95
|
},
|
|
96
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "45cd961cf956d2d28e4d09b20db4204982c33593"
|
|
97
97
|
}
|