@constructive-io/graphql-server 5.33.5 → 5.34.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.
@@ -4,6 +4,7 @@ import { DEFAULT_REQUEST_PROTECTION, protectionPgSettings } from '@constructive-
4
4
  import { Logger } from '@pgpmjs/logger';
5
5
  import { cacheGraphileInstance, createGraphileInstance, graphileCache } from 'graphile-cache';
6
6
  import { createFunctionBindingsPlugin } from 'graphile-function-bindings';
7
+ import { FunctionFromSourcePreset } from 'graphile-function-source';
7
8
  import { createConstructivePreset, createGrafastCacheLimitsPreset } from 'graphile-settings';
8
9
  import { isGraphqlObservabilityEnabled } from '../diagnostics/observability';
9
10
  import { HandlerCreationError } from '../errors/api-errors';
@@ -54,7 +55,7 @@ const reqLabel = (req) => (req.requestId ? `[${req.requestId}]` : '[req]');
54
55
  * plugin preset. Without settings the default preset is used
55
56
  * (everything on except aggregates).
56
57
  */
57
- const buildPreset = (pool, schemas, anonRole, roleName, introspectionRole, graphileOptions, databaseSettings, apiId, compute, webauthn) => {
58
+ const buildPreset = (pool, schemas, anonRole, roleName, introspectionRole, graphileOptions, databaseSettings, apiId, compute, webauthn, platform) => {
58
59
  const introspection = makeIntrospectionWiring(pool, schemas, graphileOptions, introspectionRole);
59
60
  const configuredPreset = graphileOptions?.preset ?? {};
60
61
  const grafastCachePreset = createGrafastCacheLimitsPreset(graphileOptions?.grafastCache);
@@ -62,6 +63,9 @@ const buildPreset = (pool, schemas, anonRole, roleName, introspectionRole, graph
62
63
  ...configuredPreset,
63
64
  extends: [
64
65
  createConstructivePreset(databaseSettings),
66
+ // Only on the platform database's own APIs: a tenant never authors
67
+ // functions through these mutations.
68
+ ...(platform ? [FunctionFromSourcePreset] : []),
65
69
  ...(graphileOptions?.extends ?? []),
66
70
  ...(configuredPreset.extends ?? []),
67
71
  ...introspection.presets,
@@ -308,7 +312,8 @@ export const graphile = (opts) => {
308
312
  // concurrent requests coalesce while optional plugin modules load.
309
313
  const creationPromise = (async () => {
310
314
  const compute = api.apiId ? await req.constructive?.useModule('compute') : undefined;
311
- const preset = buildPreset(pool, schema || [], anonRole, roleName, opts.api?.introspectionRole, opts.graphile, api.databaseSettings, api.apiId, compute, Boolean(api.webauthnSettings));
315
+ const platform = api.databaseId ? await req.constructive?.useModule('platform') : undefined;
316
+ const preset = buildPreset(pool, schema || [], anonRole, roleName, opts.api?.introspectionRole, opts.graphile, api.databaseSettings, api.apiId, compute, Boolean(api.webauthnSettings), platform?.platform);
312
317
  const instance = await observeGraphileBuild({
313
318
  cacheKey: key,
314
319
  serviceKey: key,
@@ -10,6 +10,7 @@ const express_context_1 = require("@constructive-io/express-context");
10
10
  const logger_1 = require("@pgpmjs/logger");
11
11
  const graphile_cache_1 = require("graphile-cache");
12
12
  const graphile_function_bindings_1 = require("graphile-function-bindings");
13
+ const graphile_function_source_1 = require("graphile-function-source");
13
14
  const graphile_settings_1 = require("graphile-settings");
14
15
  const observability_1 = require("../diagnostics/observability");
15
16
  const api_errors_1 = require("../errors/api-errors");
@@ -60,7 +61,7 @@ const reqLabel = (req) => (req.requestId ? `[${req.requestId}]` : '[req]');
60
61
  * plugin preset. Without settings the default preset is used
61
62
  * (everything on except aggregates).
62
63
  */
63
- const buildPreset = (pool, schemas, anonRole, roleName, introspectionRole, graphileOptions, databaseSettings, apiId, compute, webauthn) => {
64
+ const buildPreset = (pool, schemas, anonRole, roleName, introspectionRole, graphileOptions, databaseSettings, apiId, compute, webauthn, platform) => {
64
65
  const introspection = (0, graphile_introspection_1.makeIntrospectionWiring)(pool, schemas, graphileOptions, introspectionRole);
65
66
  const configuredPreset = graphileOptions?.preset ?? {};
66
67
  const grafastCachePreset = (0, graphile_settings_1.createGrafastCacheLimitsPreset)(graphileOptions?.grafastCache);
@@ -68,6 +69,9 @@ const buildPreset = (pool, schemas, anonRole, roleName, introspectionRole, graph
68
69
  ...configuredPreset,
69
70
  extends: [
70
71
  (0, graphile_settings_1.createConstructivePreset)(databaseSettings),
72
+ // Only on the platform database's own APIs: a tenant never authors
73
+ // functions through these mutations.
74
+ ...(platform ? [graphile_function_source_1.FunctionFromSourcePreset] : []),
71
75
  ...(graphileOptions?.extends ?? []),
72
76
  ...(configuredPreset.extends ?? []),
73
77
  ...introspection.presets,
@@ -314,7 +318,8 @@ const graphile = (opts) => {
314
318
  // concurrent requests coalesce while optional plugin modules load.
315
319
  const creationPromise = (async () => {
316
320
  const compute = api.apiId ? await req.constructive?.useModule('compute') : undefined;
317
- const preset = buildPreset(pool, schema || [], anonRole, roleName, opts.api?.introspectionRole, opts.graphile, api.databaseSettings, api.apiId, compute, Boolean(api.webauthnSettings));
321
+ const platform = api.databaseId ? await req.constructive?.useModule('platform') : undefined;
322
+ const preset = buildPreset(pool, schema || [], anonRole, roleName, opts.api?.introspectionRole, opts.graphile, api.databaseSettings, api.apiId, compute, Boolean(api.webauthnSettings), platform?.platform);
318
323
  const instance = await (0, graphile_build_stats_1.observeGraphileBuild)({
319
324
  cacheKey: key,
320
325
  serviceKey: key,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@constructive-io/graphql-server",
3
- "version": "5.33.5",
3
+ "version": "5.34.0",
4
4
  "author": "Constructive <developers@constructive.io>",
5
5
  "description": "Constructive GraphQL Server",
6
6
  "main": "index.js",
@@ -43,7 +43,7 @@
43
43
  "@agentic-kit/ollama": "2.16.0",
44
44
  "@constructive-io/csrf": "^0.31.0",
45
45
  "@constructive-io/errors": "^0.25.0",
46
- "@constructive-io/express-context": "^0.35.4",
46
+ "@constructive-io/express-context": "^0.36.0",
47
47
  "@constructive-io/graphql-env": "^3.37.2",
48
48
  "@constructive-io/graphql-types": "^3.36.1",
49
49
  "@constructive-io/llm-env": "^0.16.0",
@@ -69,10 +69,11 @@
69
69
  "graphile-cache": "^4.16.1",
70
70
  "graphile-config": "1.1.0",
71
71
  "graphile-function-bindings": "^1.19.0",
72
+ "graphile-function-source": "^0.3.0",
72
73
  "graphile-plugin-utils": "^1.14.1",
73
74
  "graphile-presigned-url-plugin": "^1.23.4",
74
75
  "graphile-scoped-introspection": "^0.6.0",
75
- "graphile-settings": "^6.28.4",
76
+ "graphile-settings": "^6.29.0",
76
77
  "graphile-utils": "5.0.3",
77
78
  "graphql": "16.13.0",
78
79
  "graphql-upload": "^13.0.0",
@@ -98,5 +99,5 @@
98
99
  "supertest": "^7.2.2",
99
100
  "ts-node": "^10.9.2"
100
101
  },
101
- "gitHead": "ed0726630bf8211ff3f58934e0e0b70a180284db"
102
+ "gitHead": "3e55ca27382b58c3cab2b32e86d1690d0cdae8ce"
102
103
  }