@constructive-io/graphql-env 3.36.1 → 3.37.1
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/README.md +12 -28
- package/esm/scoped-introspection.d.ts +3 -3
- package/esm/scoped-introspection.js +4 -16
- package/package.json +5 -5
- package/scoped-introspection.d.ts +3 -3
- package/scoped-introspection.js +3 -15
package/README.md
CHANGED
|
@@ -44,11 +44,13 @@ In addition to all environment variables supported by `@pgpmjs/env`, this packag
|
|
|
44
44
|
### GraphQL Schema
|
|
45
45
|
- `GRAPHILE_SCHEMA` - Comma-separated list of PostgreSQL schemas to expose
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
The server always uses schema-scoped introspection for its `main` PostgreSQL
|
|
48
|
+
service: each handler introspects only its API's schemas and their dependency
|
|
49
|
+
closure. There is no switch back to stock introspection (`main: false` is
|
|
50
|
+
rejected), because stock introspection retains the whole database in every
|
|
51
|
+
cached handler. The scoped options are configured through the Graphile preset
|
|
52
|
+
in `pgpm.json` or runtime options under
|
|
53
|
+
`graphile.preset.gather.pgScopedIntrospection.main`.
|
|
52
54
|
|
|
53
55
|
### Scoped introspection environment overrides
|
|
54
56
|
|
|
@@ -58,41 +60,23 @@ PostgreSQL service name, not the routing service name (such as `local`).
|
|
|
58
60
|
|
|
59
61
|
| Variable | Accepted values |
|
|
60
62
|
| --- | --- |
|
|
61
|
-
| `GRAPHILE_SCOPED_INTROSPECTION` | `true` or `false` |
|
|
62
63
|
| `GRAPHILE_SCOPED_INTROSPECTION_CATALOG_TYPES` | `all` or `dependency-closure` |
|
|
63
64
|
| `GRAPHILE_SCOPED_INTROSPECTION_CAPABILITY_EXTENSIONS` | Comma-separated extension names, e.g. `pg_trgm,vector` |
|
|
64
65
|
|
|
65
|
-
- Unset variables do not override `pgpm.json`. With neither
|
|
66
|
-
|
|
67
|
-
-
|
|
68
|
-
`pgpm.json`; without advanced options it uses Crystal's defaults
|
|
69
|
-
(`catalogTypes: "all"`).
|
|
70
|
-
- Either advanced variable alone enables scoped introspection, including when
|
|
71
|
-
the config file sets `main: false`.
|
|
72
|
-
- Explicit `false` overrides both advanced variables and the config file.
|
|
73
|
-
Advanced variables are ignored, even if malformed, so one switch is enough
|
|
74
|
-
to roll back to stock.
|
|
75
|
-
- Advanced options override only their own field. Extension lists replace the
|
|
66
|
+
- Unset variables do not override `pgpm.json`. With neither, the server uses
|
|
67
|
+
Crystal's defaults (`catalogTypes: "all"`).
|
|
68
|
+
- Each variable overrides only its own field. Extension lists replace the
|
|
76
69
|
configured array, trim names and remove duplicates. An explicitly empty or
|
|
77
70
|
whitespace-only extension variable clears the list to `[]`; unset preserves it.
|
|
78
|
-
-
|
|
79
|
-
must be lowercase `true` or `false` (surrounding whitespace is allowed).
|
|
80
|
-
Catalog values must match one of the two lowercase choices exactly; an empty
|
|
71
|
+
- Catalog values must match one of the two lowercase choices exactly; an empty
|
|
81
72
|
catalog value is invalid. Empty CSV items such as `pg_trgm,,vector` are invalid.
|
|
82
|
-
Invalid
|
|
73
|
+
Invalid settings fail option resolution with the variable name.
|
|
83
74
|
- Precedence remains defaults < config file < environment < explicit runtime
|
|
84
75
|
options. These variables affect only `main`.
|
|
85
76
|
|
|
86
77
|
```bash
|
|
87
|
-
# Enable default scoped introspection
|
|
88
|
-
export GRAPHILE_SCOPED_INTROSPECTION=true
|
|
89
|
-
|
|
90
|
-
# Optionally customize it
|
|
91
78
|
export GRAPHILE_SCOPED_INTROSPECTION_CATALOG_TYPES=dependency-closure
|
|
92
79
|
export GRAPHILE_SCOPED_INTROSPECTION_CAPABILITY_EXTENSIONS=pg_trgm,vector
|
|
93
|
-
|
|
94
|
-
# Roll back without removing the advanced variables
|
|
95
|
-
export GRAPHILE_SCOPED_INTROSPECTION=false
|
|
96
80
|
```
|
|
97
81
|
|
|
98
82
|
Restart the server after changing its environment. `capabilityExtensions`
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** Partial override for the server-owned `main` service
|
|
3
|
-
export declare const getScopedIntrospectionEnv: (environment: NodeJS.ProcessEnv) =>
|
|
1
|
+
import type { SchemaScopedIntrospectionOptions } from '@constructive-io/graphql-types';
|
|
2
|
+
/** Partial override for the server-owned `main` service's scoped introspection options. */
|
|
3
|
+
export declare const getScopedIntrospectionEnv: (environment: NodeJS.ProcessEnv) => SchemaScopedIntrospectionOptions | undefined;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { cleanEnv, enumerated, EnvError, makeValidator, parseEnvList
|
|
1
|
+
import { cleanEnv, enumerated, EnvError, makeValidator, parseEnvList } from '12factor-env';
|
|
2
2
|
// Unlike the generic list validator, this configuration permits an explicit
|
|
3
3
|
// empty list (clear the configured extensions), but rejects empty CSV items.
|
|
4
4
|
const capabilityExtensions = makeValidator((value) => {
|
|
@@ -9,19 +9,8 @@ const capabilityExtensions = makeValidator((value) => {
|
|
|
9
9
|
}
|
|
10
10
|
return [...new Set(parseEnvList(value))];
|
|
11
11
|
});
|
|
12
|
-
/** Partial override for the server-owned `main` service
|
|
12
|
+
/** Partial override for the server-owned `main` service's scoped introspection options. */
|
|
13
13
|
export const getScopedIntrospectionEnv = (environment) => {
|
|
14
|
-
const enabled = cleanEnv({
|
|
15
|
-
GRAPHILE_SCOPED_INTROSPECTION: environment.GRAPHILE_SCOPED_INTROSPECTION?.trim() || undefined
|
|
16
|
-
}, {
|
|
17
|
-
GRAPHILE_SCOPED_INTROSPECTION: str({
|
|
18
|
-
choices: ['true', 'false'],
|
|
19
|
-
default: undefined
|
|
20
|
-
})
|
|
21
|
-
}).GRAPHILE_SCOPED_INTROSPECTION;
|
|
22
|
-
// The rollback switch works even if stale advanced settings are malformed.
|
|
23
|
-
if (enabled === 'false')
|
|
24
|
-
return false;
|
|
25
14
|
const options = cleanEnv(environment, {
|
|
26
15
|
GRAPHILE_SCOPED_INTROSPECTION_CATALOG_TYPES: enumerated(['all', 'dependency-closure'], { default: undefined }),
|
|
27
16
|
GRAPHILE_SCOPED_INTROSPECTION_CAPABILITY_EXTENSIONS: capabilityExtensions({
|
|
@@ -30,11 +19,10 @@ export const getScopedIntrospectionEnv = (environment) => {
|
|
|
30
19
|
});
|
|
31
20
|
const catalogTypes = options.GRAPHILE_SCOPED_INTROSPECTION_CATALOG_TYPES;
|
|
32
21
|
const extensions = options.GRAPHILE_SCOPED_INTROSPECTION_CAPABILITY_EXTENSIONS;
|
|
33
|
-
if (
|
|
22
|
+
if (catalogTypes === undefined && extensions === undefined) {
|
|
34
23
|
return undefined;
|
|
35
24
|
}
|
|
36
|
-
//
|
|
37
|
-
// fields from pgpm.json. A literal `true` would discard those fields.
|
|
25
|
+
// deepmerge keeps the other option fields configured in pgpm.json.
|
|
38
26
|
return {
|
|
39
27
|
...(catalogTypes !== undefined && { catalogTypes }),
|
|
40
28
|
...(extensions !== undefined && { capabilityExtensions: extensions })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@constructive-io/graphql-env",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.37.1",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "Constructive environment configuration with GraphQL/Graphile support",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,9 +29,9 @@
|
|
|
29
29
|
"test:watch": "jest --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"12factor-env": "^1.
|
|
33
|
-
"@constructive-io/graphql-types": "^3.
|
|
34
|
-
"@pgpmjs/env": "^2.
|
|
32
|
+
"12factor-env": "^1.34.0",
|
|
33
|
+
"@constructive-io/graphql-types": "^3.36.0",
|
|
34
|
+
"@pgpmjs/env": "^2.48.0",
|
|
35
35
|
"deepmerge": "^4.3.1"
|
|
36
36
|
},
|
|
37
37
|
"keywords": [
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"makage": "^0.8.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "91e18cc80da92331fb3aadd5baa43251c8934bc8"
|
|
49
49
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** Partial override for the server-owned `main` service
|
|
3
|
-
export declare const getScopedIntrospectionEnv: (environment: NodeJS.ProcessEnv) =>
|
|
1
|
+
import type { SchemaScopedIntrospectionOptions } from '@constructive-io/graphql-types';
|
|
2
|
+
/** Partial override for the server-owned `main` service's scoped introspection options. */
|
|
3
|
+
export declare const getScopedIntrospectionEnv: (environment: NodeJS.ProcessEnv) => SchemaScopedIntrospectionOptions | undefined;
|
package/scoped-introspection.js
CHANGED
|
@@ -12,19 +12,8 @@ const capabilityExtensions = (0, _12factor_env_1.makeValidator)((value) => {
|
|
|
12
12
|
}
|
|
13
13
|
return [...new Set((0, _12factor_env_1.parseEnvList)(value))];
|
|
14
14
|
});
|
|
15
|
-
/** Partial override for the server-owned `main` service
|
|
15
|
+
/** Partial override for the server-owned `main` service's scoped introspection options. */
|
|
16
16
|
const getScopedIntrospectionEnv = (environment) => {
|
|
17
|
-
const enabled = (0, _12factor_env_1.cleanEnv)({
|
|
18
|
-
GRAPHILE_SCOPED_INTROSPECTION: environment.GRAPHILE_SCOPED_INTROSPECTION?.trim() || undefined
|
|
19
|
-
}, {
|
|
20
|
-
GRAPHILE_SCOPED_INTROSPECTION: (0, _12factor_env_1.str)({
|
|
21
|
-
choices: ['true', 'false'],
|
|
22
|
-
default: undefined
|
|
23
|
-
})
|
|
24
|
-
}).GRAPHILE_SCOPED_INTROSPECTION;
|
|
25
|
-
// The rollback switch works even if stale advanced settings are malformed.
|
|
26
|
-
if (enabled === 'false')
|
|
27
|
-
return false;
|
|
28
17
|
const options = (0, _12factor_env_1.cleanEnv)(environment, {
|
|
29
18
|
GRAPHILE_SCOPED_INTROSPECTION_CATALOG_TYPES: (0, _12factor_env_1.enumerated)(['all', 'dependency-closure'], { default: undefined }),
|
|
30
19
|
GRAPHILE_SCOPED_INTROSPECTION_CAPABILITY_EXTENSIONS: capabilityExtensions({
|
|
@@ -33,11 +22,10 @@ const getScopedIntrospectionEnv = (environment) => {
|
|
|
33
22
|
});
|
|
34
23
|
const catalogTypes = options.GRAPHILE_SCOPED_INTROSPECTION_CATALOG_TYPES;
|
|
35
24
|
const extensions = options.GRAPHILE_SCOPED_INTROSPECTION_CAPABILITY_EXTENSIONS;
|
|
36
|
-
if (
|
|
25
|
+
if (catalogTypes === undefined && extensions === undefined) {
|
|
37
26
|
return undefined;
|
|
38
27
|
}
|
|
39
|
-
//
|
|
40
|
-
// fields from pgpm.json. A literal `true` would discard those fields.
|
|
28
|
+
// deepmerge keeps the other option fields configured in pgpm.json.
|
|
41
29
|
return {
|
|
42
30
|
...(catalogTypes !== undefined && { catalogTypes }),
|
|
43
31
|
...(extensions !== undefined && { capabilityExtensions: extensions })
|