graphile-settings 3.1.1 → 4.0.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/README.md +170 -85
- package/esm/index.d.ts +37 -0
- package/esm/index.js +54 -103
- package/esm/plugins/conflict-detector.d.ts +7 -0
- package/esm/plugins/conflict-detector.js +55 -0
- package/esm/plugins/custom-inflector.d.ts +9 -0
- package/esm/plugins/custom-inflector.js +382 -0
- package/esm/plugins/enable-all-filter-columns.d.ts +60 -0
- package/esm/plugins/enable-all-filter-columns.js +85 -0
- package/esm/plugins/index.d.ts +19 -0
- package/esm/plugins/index.js +26 -0
- package/esm/plugins/inflector-logger.d.ts +7 -0
- package/esm/plugins/inflector-logger.js +215 -0
- package/esm/plugins/many-to-many-preset.d.ts +62 -0
- package/esm/plugins/many-to-many-preset.js +86 -0
- package/esm/plugins/meta-schema/cache.d.ts +4 -0
- package/esm/plugins/meta-schema/cache.js +7 -0
- package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +13 -0
- package/esm/plugins/meta-schema/constraint-meta-builders.js +51 -0
- package/esm/plugins/meta-schema/graphql-meta-field.d.ts +4 -0
- package/esm/plugins/meta-schema/graphql-meta-field.js +201 -0
- package/esm/plugins/meta-schema/inflection-utils.d.ts +4 -0
- package/esm/plugins/meta-schema/inflection-utils.js +20 -0
- package/esm/plugins/meta-schema/name-meta-builders.d.ts +4 -0
- package/esm/plugins/meta-schema/name-meta-builders.js +38 -0
- package/esm/plugins/meta-schema/plugin.d.ts +2 -0
- package/esm/plugins/meta-schema/plugin.js +23 -0
- package/esm/plugins/meta-schema/relation-meta-builders.d.ts +8 -0
- package/esm/plugins/meta-schema/relation-meta-builders.js +115 -0
- package/esm/plugins/meta-schema/table-meta-builder.d.ts +2 -0
- package/esm/plugins/meta-schema/table-meta-builder.js +69 -0
- package/esm/plugins/meta-schema/table-meta-context.d.ts +13 -0
- package/esm/plugins/meta-schema/table-meta-context.js +11 -0
- package/esm/plugins/meta-schema/table-resource-utils.d.ts +12 -0
- package/esm/plugins/meta-schema/table-resource-utils.js +50 -0
- package/esm/plugins/meta-schema/type-mappings.d.ts +3 -0
- package/esm/plugins/meta-schema/type-mappings.js +75 -0
- package/esm/plugins/meta-schema/types.d.ts +206 -0
- package/esm/plugins/meta-schema/types.js +1 -0
- package/esm/plugins/meta-schema.d.ts +19 -0
- package/esm/plugins/meta-schema.js +20 -0
- package/esm/plugins/minimal-preset.d.ts +7 -0
- package/esm/plugins/minimal-preset.js +42 -0
- package/esm/plugins/pg-type-mappings.d.ts +41 -0
- package/esm/plugins/pg-type-mappings.js +122 -0
- package/esm/plugins/primary-key-only.d.ts +96 -0
- package/esm/plugins/primary-key-only.js +143 -0
- package/esm/presets/constructive-preset.d.ts +40 -0
- package/esm/presets/constructive-preset.js +137 -0
- package/esm/presets/index.d.ts +7 -0
- package/esm/presets/index.js +7 -0
- package/index.d.ts +37 -3
- package/index.js +56 -129
- package/package.json +16 -22
- package/plugins/conflict-detector.d.ts +7 -0
- package/plugins/conflict-detector.js +58 -0
- package/plugins/custom-inflector.d.ts +9 -0
- package/plugins/custom-inflector.js +385 -0
- package/plugins/enable-all-filter-columns.d.ts +60 -0
- package/plugins/enable-all-filter-columns.js +88 -0
- package/plugins/index.d.ts +19 -0
- package/plugins/index.js +56 -0
- package/plugins/inflector-logger.d.ts +7 -0
- package/plugins/inflector-logger.js +218 -0
- package/plugins/many-to-many-preset.d.ts +62 -0
- package/plugins/many-to-many-preset.js +89 -0
- package/plugins/meta-schema/cache.d.ts +4 -0
- package/plugins/meta-schema/cache.js +12 -0
- package/plugins/meta-schema/constraint-meta-builders.d.ts +13 -0
- package/plugins/meta-schema/constraint-meta-builders.js +58 -0
- package/plugins/meta-schema/graphql-meta-field.d.ts +4 -0
- package/plugins/meta-schema/graphql-meta-field.js +204 -0
- package/plugins/meta-schema/inflection-utils.d.ts +4 -0
- package/plugins/meta-schema/inflection-utils.js +25 -0
- package/plugins/meta-schema/name-meta-builders.d.ts +4 -0
- package/plugins/meta-schema/name-meta-builders.js +43 -0
- package/plugins/meta-schema/plugin.d.ts +2 -0
- package/plugins/meta-schema/plugin.js +26 -0
- package/plugins/meta-schema/relation-meta-builders.d.ts +8 -0
- package/plugins/meta-schema/relation-meta-builders.js +120 -0
- package/plugins/meta-schema/table-meta-builder.d.ts +2 -0
- package/plugins/meta-schema/table-meta-builder.js +72 -0
- package/plugins/meta-schema/table-meta-context.d.ts +13 -0
- package/plugins/meta-schema/table-meta-context.js +15 -0
- package/plugins/meta-schema/table-resource-utils.d.ts +12 -0
- package/plugins/meta-schema/table-resource-utils.js +60 -0
- package/plugins/meta-schema/type-mappings.d.ts +3 -0
- package/plugins/meta-schema/type-mappings.js +79 -0
- package/plugins/meta-schema/types.d.ts +206 -0
- package/plugins/meta-schema/types.js +2 -0
- package/plugins/meta-schema.d.ts +19 -0
- package/plugins/meta-schema.js +20 -0
- package/plugins/minimal-preset.d.ts +7 -0
- package/plugins/minimal-preset.js +45 -0
- package/plugins/pg-type-mappings.d.ts +41 -0
- package/plugins/pg-type-mappings.js +128 -0
- package/plugins/primary-key-only.d.ts +96 -0
- package/plugins/primary-key-only.js +147 -0
- package/presets/constructive-preset.d.ts +40 -0
- package/presets/constructive-preset.js +140 -0
- package/presets/index.d.ts +7 -0
- package/presets/index.js +11 -0
package/index.d.ts
CHANGED
|
@@ -1,3 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* graphile-settings
|
|
3
|
+
*
|
|
4
|
+
* Shared PostGraphile v5 settings, presets, and plugins for Constructive.
|
|
5
|
+
*
|
|
6
|
+
* This package provides:
|
|
7
|
+
* - Custom plugins for PostGraphile v5
|
|
8
|
+
* - Pre-configured presets combining multiple plugins
|
|
9
|
+
*
|
|
10
|
+
* USAGE:
|
|
11
|
+
*
|
|
12
|
+
* 1. Use the main preset:
|
|
13
|
+
* ```typescript
|
|
14
|
+
* import { ConstructivePreset, makePgService } from 'graphile-settings';
|
|
15
|
+
* import { makeSchema } from 'graphile-build';
|
|
16
|
+
*
|
|
17
|
+
* const preset = {
|
|
18
|
+
* extends: [ConstructivePreset],
|
|
19
|
+
* pgServices: [makePgService({ connectionString, schemas })],
|
|
20
|
+
* };
|
|
21
|
+
* const { schema } = await makeSchema(preset);
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* 2. Use individual plugins:
|
|
25
|
+
* ```typescript
|
|
26
|
+
* import { MinimalPreset, InflektPreset } from 'graphile-settings/plugins';
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
import { makePgService } from 'postgraphile/adaptors/pg';
|
|
30
|
+
import 'postgraphile/grafserv';
|
|
31
|
+
import 'graphile-build';
|
|
32
|
+
export { ConstructivePreset } from './presets/constructive-preset';
|
|
33
|
+
export * from './plugins/index';
|
|
34
|
+
export * from './presets/index';
|
|
35
|
+
import { MinimalPreset } from './plugins/minimal-preset';
|
|
36
|
+
export { MinimalPreset };
|
|
37
|
+
export { makePgService };
|
package/index.js
CHANGED
|
@@ -1,4 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* graphile-settings
|
|
4
|
+
*
|
|
5
|
+
* Shared PostGraphile v5 settings, presets, and plugins for Constructive.
|
|
6
|
+
*
|
|
7
|
+
* This package provides:
|
|
8
|
+
* - Custom plugins for PostGraphile v5
|
|
9
|
+
* - Pre-configured presets combining multiple plugins
|
|
10
|
+
*
|
|
11
|
+
* USAGE:
|
|
12
|
+
*
|
|
13
|
+
* 1. Use the main preset:
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import { ConstructivePreset, makePgService } from 'graphile-settings';
|
|
16
|
+
* import { makeSchema } from 'graphile-build';
|
|
17
|
+
*
|
|
18
|
+
* const preset = {
|
|
19
|
+
* extends: [ConstructivePreset],
|
|
20
|
+
* pgServices: [makePgService({ connectionString, schemas })],
|
|
21
|
+
* };
|
|
22
|
+
* const { schema } = await makeSchema(preset);
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* 2. Use individual plugins:
|
|
26
|
+
* ```typescript
|
|
27
|
+
* import { MinimalPreset, InflektPreset } from 'graphile-settings/plugins';
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
2
30
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
31
|
if (k2 === undefined) k2 = k;
|
|
4
32
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -10,134 +38,33 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
10
38
|
if (k2 === undefined) k2 = k;
|
|
11
39
|
o[k2] = m[k];
|
|
12
40
|
}));
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
42
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
43
|
};
|
|
38
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const resolveUpload = uploader.resolveUpload.bind(uploader);
|
|
66
|
-
const plugins = [
|
|
67
|
-
graphile_plugin_connection_filter_1.default,
|
|
68
|
-
graphile_plugin_fulltext_filter_1.default,
|
|
69
|
-
graphile_pg_type_mappings_1.default,
|
|
70
|
-
graphile_upload_plugin_1.default,
|
|
71
|
-
graphile_meta_schema_1.default,
|
|
72
|
-
pg_many_to_many_1.default,
|
|
73
|
-
graphile_search_plugin_1.default,
|
|
74
|
-
];
|
|
75
|
-
if (features?.postgis) {
|
|
76
|
-
plugins.push(graphile_postgis_1.default, graphile_plugin_connection_filter_postgis_1.default);
|
|
77
|
-
}
|
|
78
|
-
if (features?.simpleInflection) {
|
|
79
|
-
plugins.push(graphile_simple_inflector_1.default);
|
|
80
|
-
}
|
|
81
|
-
plugins.push(graphile_i18n_1.LangPlugin);
|
|
82
|
-
return {
|
|
83
|
-
graphileBuildOptions: {
|
|
84
|
-
uploadFieldDefinitions: [
|
|
85
|
-
{
|
|
86
|
-
name: 'upload',
|
|
87
|
-
namespaceName: 'public',
|
|
88
|
-
type: 'JSON',
|
|
89
|
-
resolve: resolveUpload,
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
name: 'attachment',
|
|
93
|
-
namespaceName: 'public',
|
|
94
|
-
type: 'String',
|
|
95
|
-
resolve: resolveUpload,
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
name: 'image',
|
|
99
|
-
namespaceName: 'public',
|
|
100
|
-
type: 'JSON',
|
|
101
|
-
resolve: resolveUpload,
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
tag: 'upload',
|
|
105
|
-
resolve: resolveUpload,
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
pgSimplifyOppositeBaseNames: features?.oppositeBaseNames,
|
|
109
|
-
connectionFilterComputedColumns: false,
|
|
110
|
-
},
|
|
111
|
-
appendPlugins: plugins,
|
|
112
|
-
skipPlugins: [graphile_build_1.NodePlugin],
|
|
113
|
-
dynamicJson: true,
|
|
114
|
-
disableGraphiql: false,
|
|
115
|
-
enhanceGraphiql: true,
|
|
116
|
-
enableQueryBatching: true,
|
|
117
|
-
graphiql: true,
|
|
118
|
-
watch: false,
|
|
119
|
-
port: server?.port,
|
|
120
|
-
host: server?.host,
|
|
121
|
-
schema: graphile?.schema,
|
|
122
|
-
ignoreRBAC: false,
|
|
123
|
-
legacyRelations: 'omit',
|
|
124
|
-
showErrorStack: false,
|
|
125
|
-
// @ts-ignore
|
|
126
|
-
extendedErrors: false,
|
|
127
|
-
disableQueryLog: false,
|
|
128
|
-
includeExtensionResources: true,
|
|
129
|
-
setofFunctionsContainNulls: false,
|
|
130
|
-
retryOnInitFail: async (_error) => {
|
|
131
|
-
return false;
|
|
132
|
-
},
|
|
133
|
-
additionalGraphQLContextFromRequest: async (req, res) => {
|
|
134
|
-
const langContext = await (0, graphile_i18n_1.additionalGraphQLContextFromRequest)(req, res);
|
|
135
|
-
return {
|
|
136
|
-
...langContext,
|
|
137
|
-
req,
|
|
138
|
-
res,
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
};
|
|
143
|
-
exports.getGraphileSettings = getGraphileSettings;
|
|
45
|
+
exports.makePgService = exports.MinimalPreset = exports.ConstructivePreset = void 0;
|
|
46
|
+
const pg_1 = require("postgraphile/adaptors/pg");
|
|
47
|
+
Object.defineProperty(exports, "makePgService", { enumerable: true, get: function () { return pg_1.makePgService; } });
|
|
48
|
+
// Import modules for type augmentation
|
|
49
|
+
// These add properties to the GraphileConfig.Preset interface:
|
|
50
|
+
// - grafserv: adds 'grafserv' property
|
|
51
|
+
// - graphile-build: adds 'schema' property (typed as GraphileBuild.SchemaOptions)
|
|
52
|
+
// - postgraphile-plugin-connection-filter: augments SchemaOptions with connectionFilter* options
|
|
53
|
+
require("postgraphile/grafserv");
|
|
54
|
+
require("graphile-build");
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Re-export all plugins and presets
|
|
57
|
+
// ============================================================================
|
|
58
|
+
// Main preset
|
|
59
|
+
var constructive_preset_1 = require("./presets/constructive-preset");
|
|
60
|
+
Object.defineProperty(exports, "ConstructivePreset", { enumerable: true, get: function () { return constructive_preset_1.ConstructivePreset; } });
|
|
61
|
+
// Re-export all plugins for convenience
|
|
62
|
+
__exportStar(require("./plugins/index"), exports);
|
|
63
|
+
// Re-export presets
|
|
64
|
+
__exportStar(require("./presets/index"), exports);
|
|
65
|
+
// ============================================================================
|
|
66
|
+
// Utilities
|
|
67
|
+
// ============================================================================
|
|
68
|
+
// Import the new MinimalPreset from plugins
|
|
69
|
+
const minimal_preset_1 = require("./plugins/minimal-preset");
|
|
70
|
+
Object.defineProperty(exports, "MinimalPreset", { enumerable: true, get: function () { return minimal_preset_1.MinimalPreset; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-settings",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "graphile settings",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,30 +29,24 @@
|
|
|
29
29
|
"test:watch": "jest --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@constructive-io/graphql-env": "^
|
|
33
|
-
"@constructive-io/graphql-types": "^
|
|
34
|
-
"@graphile-contrib/pg-many-to-many": "
|
|
32
|
+
"@constructive-io/graphql-env": "^3.0.0",
|
|
33
|
+
"@constructive-io/graphql-types": "^3.0.0",
|
|
34
|
+
"@graphile-contrib/pg-many-to-many": "2.0.0-rc.1",
|
|
35
35
|
"@pgpmjs/types": "^2.16.0",
|
|
36
36
|
"cors": "^2.8.5",
|
|
37
37
|
"express": "^5.2.1",
|
|
38
|
-
"
|
|
39
|
-
"graphile-
|
|
40
|
-
"graphile-
|
|
41
|
-
"graphile-
|
|
42
|
-
"graphile-plugin
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"graphile-postgis": "^1.1.1",
|
|
46
|
-
"graphile-query": "^2.6.0",
|
|
47
|
-
"graphile-search-plugin": "^1.1.1",
|
|
48
|
-
"graphile-simple-inflector": "^1.1.1",
|
|
49
|
-
"graphile-upload-plugin": "^1.1.1",
|
|
50
|
-
"graphql": "15.10.1",
|
|
51
|
-
"graphql-tag": "2.12.6",
|
|
52
|
-
"graphql-upload": "^13.0.0",
|
|
38
|
+
"grafast": "^1.0.0-rc.4",
|
|
39
|
+
"graphile-build": "^5.0.0-rc.3",
|
|
40
|
+
"graphile-build-pg": "^5.0.0-rc.3",
|
|
41
|
+
"graphile-config": "1.0.0-rc.3",
|
|
42
|
+
"graphile-search-plugin": "^3.0.0",
|
|
43
|
+
"graphql": "^16.9.0",
|
|
44
|
+
"inflekt": "^0.3.0",
|
|
53
45
|
"lru-cache": "^11.2.4",
|
|
54
46
|
"pg": "^8.17.1",
|
|
55
|
-
"
|
|
47
|
+
"pg-sql2": "^5.0.0-rc.3",
|
|
48
|
+
"postgraphile": "^5.0.0-rc.4",
|
|
49
|
+
"postgraphile-plugin-connection-filter": "^3.0.0-rc.1",
|
|
56
50
|
"request-ip": "^3.3.0"
|
|
57
51
|
},
|
|
58
52
|
"devDependencies": {
|
|
@@ -60,7 +54,7 @@
|
|
|
60
54
|
"@types/express": "^5.0.6",
|
|
61
55
|
"@types/pg": "^8.16.0",
|
|
62
56
|
"@types/request-ip": "^0.0.41",
|
|
63
|
-
"makage": "^0.1.
|
|
57
|
+
"makage": "^0.1.10",
|
|
64
58
|
"nodemon": "^3.1.10",
|
|
65
59
|
"ts-node": "^10.9.2"
|
|
66
60
|
},
|
|
@@ -71,5 +65,5 @@
|
|
|
71
65
|
"constructive",
|
|
72
66
|
"graphql"
|
|
73
67
|
],
|
|
74
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "b2daeefe49cdefb3d01ea63cf778fb9b847ab5fe"
|
|
75
69
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { GraphileConfig } from 'graphile-config';
|
|
2
|
+
export declare const ConflictDetectorPlugin: GraphileConfig.Plugin;
|
|
3
|
+
/**
|
|
4
|
+
* Preset that includes the conflict detector plugin.
|
|
5
|
+
*/
|
|
6
|
+
export declare const ConflictDetectorPreset: GraphileConfig.Preset;
|
|
7
|
+
export default ConflictDetectorPlugin;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ConflictDetectorPreset = exports.ConflictDetectorPlugin = void 0;
|
|
4
|
+
exports.ConflictDetectorPlugin = {
|
|
5
|
+
name: 'ConflictDetectorPlugin',
|
|
6
|
+
version: '1.0.0',
|
|
7
|
+
schema: {
|
|
8
|
+
hooks: {
|
|
9
|
+
build(build) {
|
|
10
|
+
// Track codecs by their GraphQL name to detect conflicts
|
|
11
|
+
const codecsByName = new Map();
|
|
12
|
+
// Iterate through all codecs to find tables
|
|
13
|
+
for (const codec of Object.values(build.input.pgRegistry.pgCodecs)) {
|
|
14
|
+
// Skip non-table codecs (those without attributes or anonymous ones)
|
|
15
|
+
if (!codec.attributes || codec.isAnonymous)
|
|
16
|
+
continue;
|
|
17
|
+
// Get the schema name from the codec's extensions
|
|
18
|
+
const pgExtensions = codec.extensions?.pg;
|
|
19
|
+
const schemaName = pgExtensions?.schemaName || 'unknown';
|
|
20
|
+
const tableName = codec.name;
|
|
21
|
+
// Get the GraphQL name that would be generated
|
|
22
|
+
const graphqlName = build.inflection.tableType(codec);
|
|
23
|
+
const info = {
|
|
24
|
+
name: graphqlName,
|
|
25
|
+
schemaName,
|
|
26
|
+
tableName,
|
|
27
|
+
};
|
|
28
|
+
if (!codecsByName.has(graphqlName)) {
|
|
29
|
+
codecsByName.set(graphqlName, []);
|
|
30
|
+
}
|
|
31
|
+
codecsByName.get(graphqlName).push(info);
|
|
32
|
+
}
|
|
33
|
+
// Check for conflicts and log warnings
|
|
34
|
+
for (const [graphqlName, codecs] of codecsByName) {
|
|
35
|
+
if (codecs.length > 1) {
|
|
36
|
+
const locations = codecs
|
|
37
|
+
.map((c) => `${c.schemaName}.${c.tableName}`)
|
|
38
|
+
.join(', ');
|
|
39
|
+
console.warn(`\nNAMING CONFLICT DETECTED: GraphQL type "${graphqlName}" would be generated from multiple tables:\n` +
|
|
40
|
+
` Tables: ${locations}\n` +
|
|
41
|
+
` Resolution options:\n` +
|
|
42
|
+
` 1. Add @name smart tag to one table: COMMENT ON TABLE schema.table IS E'@name UniqueTypeName';\n` +
|
|
43
|
+
` 2. Rename one of the tables in the database\n` +
|
|
44
|
+
` 3. Exclude one table from the schema using @omit smart tag\n`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return build;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Preset that includes the conflict detector plugin.
|
|
54
|
+
*/
|
|
55
|
+
exports.ConflictDetectorPreset = {
|
|
56
|
+
plugins: [exports.ConflictDetectorPlugin],
|
|
57
|
+
};
|
|
58
|
+
exports.default = exports.ConflictDetectorPlugin;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { GraphileConfig } from 'graphile-config';
|
|
2
|
+
export declare const InflektPlugin: GraphileConfig.Plugin;
|
|
3
|
+
/**
|
|
4
|
+
* Preset that includes the inflekt-based inflector plugin.
|
|
5
|
+
* Use this in your main preset's `extends` array.
|
|
6
|
+
*/
|
|
7
|
+
export declare const InflektPreset: GraphileConfig.Preset;
|
|
8
|
+
export declare const CustomInflectorPlugin: GraphileConfig.Plugin;
|
|
9
|
+
export declare const CustomInflectorPreset: GraphileConfig.Preset;
|