graphile-settings 4.1.0 → 4.3.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/esm/index.d.ts +1 -2
- package/esm/index.js +2 -4
- package/esm/plugins/index.d.ts +4 -13
- package/esm/plugins/index.js +5 -21
- package/esm/presets/constructive-preset.d.ts +4 -0
- package/esm/presets/constructive-preset.js +17 -9
- package/esm/upload-resolver.d.ts +43 -0
- package/esm/upload-resolver.js +168 -0
- package/index.d.ts +1 -2
- package/index.js +4 -7
- package/package.json +26 -14
- package/plugins/index.d.ts +4 -13
- package/plugins/index.js +32 -44
- package/presets/constructive-preset.d.ts +4 -0
- package/presets/constructive-preset.js +26 -18
- package/upload-resolver.d.ts +43 -0
- package/upload-resolver.js +175 -0
- package/esm/plugins/conflict-detector.d.ts +0 -7
- package/esm/plugins/conflict-detector.js +0 -67
- package/esm/plugins/custom-inflector.d.ts +0 -9
- package/esm/plugins/custom-inflector.js +0 -382
- package/esm/plugins/enable-all-filter-columns.d.ts +0 -60
- package/esm/plugins/enable-all-filter-columns.js +0 -85
- package/esm/plugins/inflector-logger.d.ts +0 -7
- package/esm/plugins/inflector-logger.js +0 -215
- package/esm/plugins/many-to-many-preset.d.ts +0 -62
- package/esm/plugins/many-to-many-preset.js +0 -86
- package/esm/plugins/meta-schema/cache.d.ts +0 -4
- package/esm/plugins/meta-schema/cache.js +0 -7
- package/esm/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
- package/esm/plugins/meta-schema/constraint-meta-builders.js +0 -51
- package/esm/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
- package/esm/plugins/meta-schema/graphql-meta-field.js +0 -201
- package/esm/plugins/meta-schema/inflection-utils.d.ts +0 -4
- package/esm/plugins/meta-schema/inflection-utils.js +0 -20
- package/esm/plugins/meta-schema/name-meta-builders.d.ts +0 -4
- package/esm/plugins/meta-schema/name-meta-builders.js +0 -38
- package/esm/plugins/meta-schema/plugin.d.ts +0 -2
- package/esm/plugins/meta-schema/plugin.js +0 -23
- package/esm/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
- package/esm/plugins/meta-schema/relation-meta-builders.js +0 -115
- package/esm/plugins/meta-schema/table-meta-builder.d.ts +0 -2
- package/esm/plugins/meta-schema/table-meta-builder.js +0 -69
- package/esm/plugins/meta-schema/table-meta-context.d.ts +0 -13
- package/esm/plugins/meta-schema/table-meta-context.js +0 -11
- package/esm/plugins/meta-schema/table-resource-utils.d.ts +0 -12
- package/esm/plugins/meta-schema/table-resource-utils.js +0 -50
- package/esm/plugins/meta-schema/type-mappings.d.ts +0 -3
- package/esm/plugins/meta-schema/type-mappings.js +0 -75
- package/esm/plugins/meta-schema/types.d.ts +0 -206
- package/esm/plugins/meta-schema/types.js +0 -1
- package/esm/plugins/meta-schema.d.ts +0 -19
- package/esm/plugins/meta-schema.js +0 -20
- package/esm/plugins/minimal-preset.d.ts +0 -7
- package/esm/plugins/minimal-preset.js +0 -42
- package/esm/plugins/pg-type-mappings.d.ts +0 -41
- package/esm/plugins/pg-type-mappings.js +0 -122
- package/esm/plugins/primary-key-only.d.ts +0 -96
- package/esm/plugins/primary-key-only.js +0 -143
- package/plugins/conflict-detector.d.ts +0 -7
- package/plugins/conflict-detector.js +0 -70
- package/plugins/custom-inflector.d.ts +0 -9
- package/plugins/custom-inflector.js +0 -385
- package/plugins/enable-all-filter-columns.d.ts +0 -60
- package/plugins/enable-all-filter-columns.js +0 -88
- package/plugins/inflector-logger.d.ts +0 -7
- package/plugins/inflector-logger.js +0 -218
- package/plugins/many-to-many-preset.d.ts +0 -62
- package/plugins/many-to-many-preset.js +0 -89
- package/plugins/meta-schema/cache.d.ts +0 -4
- package/plugins/meta-schema/cache.js +0 -12
- package/plugins/meta-schema/constraint-meta-builders.d.ts +0 -13
- package/plugins/meta-schema/constraint-meta-builders.js +0 -58
- package/plugins/meta-schema/graphql-meta-field.d.ts +0 -4
- package/plugins/meta-schema/graphql-meta-field.js +0 -204
- package/plugins/meta-schema/inflection-utils.d.ts +0 -4
- package/plugins/meta-schema/inflection-utils.js +0 -25
- package/plugins/meta-schema/name-meta-builders.d.ts +0 -4
- package/plugins/meta-schema/name-meta-builders.js +0 -43
- package/plugins/meta-schema/plugin.d.ts +0 -2
- package/plugins/meta-schema/plugin.js +0 -26
- package/plugins/meta-schema/relation-meta-builders.d.ts +0 -8
- package/plugins/meta-schema/relation-meta-builders.js +0 -120
- package/plugins/meta-schema/table-meta-builder.d.ts +0 -2
- package/plugins/meta-schema/table-meta-builder.js +0 -72
- package/plugins/meta-schema/table-meta-context.d.ts +0 -13
- package/plugins/meta-schema/table-meta-context.js +0 -15
- package/plugins/meta-schema/table-resource-utils.d.ts +0 -12
- package/plugins/meta-schema/table-resource-utils.js +0 -60
- package/plugins/meta-schema/type-mappings.d.ts +0 -3
- package/plugins/meta-schema/type-mappings.js +0 -79
- package/plugins/meta-schema/types.d.ts +0 -206
- package/plugins/meta-schema/types.js +0 -2
- package/plugins/meta-schema.d.ts +0 -19
- package/plugins/meta-schema.js +0 -20
- package/plugins/minimal-preset.d.ts +0 -7
- package/plugins/minimal-preset.js +0 -45
- package/plugins/pg-type-mappings.d.ts +0 -41
- package/plugins/pg-type-mappings.js +0 -128
- package/plugins/primary-key-only.d.ts +0 -96
- package/plugins/primary-key-only.js +0 -147
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoUniqueLookupPreset = exports.PrimaryKeyOnlyPreset = exports.NoUniqueLookupPlugin = exports.PrimaryKeyOnlyPlugin = void 0;
|
|
4
|
-
exports.createUniqueLookupPlugin = createUniqueLookupPlugin;
|
|
5
|
-
/**
|
|
6
|
-
* PrimaryKeyOnlyPlugin - Disables non-primary-key unique constraint lookups for
|
|
7
|
-
* BOTH queries AND mutations.
|
|
8
|
-
*
|
|
9
|
-
* WHY THIS EXISTS:
|
|
10
|
-
* PostGraphile v5 creates fields for EVERY unique constraint on a table:
|
|
11
|
-
*
|
|
12
|
-
* QUERIES (PgRowByUniquePlugin):
|
|
13
|
-
* - `user(id)`, `userByEmail(email)`, `userByUsername(username)`
|
|
14
|
-
*
|
|
15
|
-
* MUTATIONS (PgMutationUpdateDeletePlugin):
|
|
16
|
-
* - `updateUser`, `updateUserByEmail`, `updateUserByUsername`
|
|
17
|
-
* - `deleteUser`, `deleteUserByEmail`, `deleteUserByUsername`
|
|
18
|
-
*
|
|
19
|
-
* For code generation (React Query, etc.), this creates unnecessary complexity.
|
|
20
|
-
* The same operations can be done using the primary key lookup or filters.
|
|
21
|
-
* Standardizing on primary keys reduces the API surface and generated code.
|
|
22
|
-
*
|
|
23
|
-
* SOURCE CODE REFERENCES:
|
|
24
|
-
*
|
|
25
|
-
* 1. Query fields (PgRowByUniquePlugin):
|
|
26
|
-
* https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgRowByUniquePlugin.ts#L42-L257
|
|
27
|
-
*
|
|
28
|
-
* The behavior check for queries:
|
|
29
|
-
* ```typescript
|
|
30
|
-
* const fieldBehaviorScope = "query:resource:single";
|
|
31
|
-
* if (!build.behavior.pgResourceUniqueMatches([resource, unique], fieldBehaviorScope)) {
|
|
32
|
-
* return memo; // Skip this field
|
|
33
|
-
* }
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* 2. Mutation fields (PgMutationUpdateDeletePlugin):
|
|
37
|
-
* https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgMutationUpdateDeletePlugin.ts
|
|
38
|
-
*
|
|
39
|
-
* The behavior check for mutations:
|
|
40
|
-
* ```typescript
|
|
41
|
-
* const constraintMode = `constraint:${mode}`; // "constraint:resource:update" or "constraint:resource:delete"
|
|
42
|
-
* ...resource.uniques.filter((unique) => {
|
|
43
|
-
* return build.behavior.pgResourceUniqueMatches([resource, unique], constraintMode);
|
|
44
|
-
* })
|
|
45
|
-
* ```
|
|
46
|
-
*
|
|
47
|
-
* OUR FIX:
|
|
48
|
-
* We use the behavior system's OVERRIDE phase (not inferred) to disable these behaviors.
|
|
49
|
-
* The override phase runs AFTER the behavior multiplication/preferences system processes
|
|
50
|
-
* behaviors, giving us the final say on what's enabled/disabled.
|
|
51
|
-
*
|
|
52
|
-
* Behaviors we control:
|
|
53
|
-
* - `-single` - Disables query lookups (userByEmail, etc.)
|
|
54
|
-
* - `-constraint:resource:update` - Disables updateByX mutations
|
|
55
|
-
* - `-constraint:resource:delete` - Disables deleteByX mutations
|
|
56
|
-
*
|
|
57
|
-
* CONFIGURATION OPTIONS:
|
|
58
|
-
*
|
|
59
|
-
* 1. `disableAllUniqueLookups: false` (default - PrimaryKeyOnlyPreset):
|
|
60
|
-
* - Primary key: query lookup + mutations enabled
|
|
61
|
-
* - Non-primary-key: everything disabled
|
|
62
|
-
* Result: `user(id)`, `updateUser`, `deleteUser` only
|
|
63
|
-
*
|
|
64
|
-
* 2. `disableAllUniqueLookups: true` (NoUniqueLookupPreset):
|
|
65
|
-
* - Primary key: query lookup DISABLED, mutations ENABLED
|
|
66
|
-
* - Non-primary-key: everything disabled
|
|
67
|
-
* Result: No query lookups (use filters), but `updateUser`, `deleteUser` still work
|
|
68
|
-
*/
|
|
69
|
-
/**
|
|
70
|
-
* Creates a plugin that controls unique constraint lookup behavior.
|
|
71
|
-
*
|
|
72
|
-
* @param options - Configuration options
|
|
73
|
-
* @param options.disableAllUniqueLookups - If true, disables ALL unique lookups including primary keys
|
|
74
|
-
*/
|
|
75
|
-
function createUniqueLookupPlugin(options = {}) {
|
|
76
|
-
const { disableAllUniqueLookups = false } = options;
|
|
77
|
-
return {
|
|
78
|
-
name: 'UniqueLookupPlugin',
|
|
79
|
-
version: '1.0.0',
|
|
80
|
-
description: disableAllUniqueLookups
|
|
81
|
-
? 'Disables all unique constraint lookups (use filters instead)'
|
|
82
|
-
: 'Disables non-primary-key unique constraint lookups to reduce API surface',
|
|
83
|
-
schema: {
|
|
84
|
-
entityBehavior: {
|
|
85
|
-
pgResourceUnique: {
|
|
86
|
-
// Use 'override' phase instead of 'inferred' - override runs AFTER
|
|
87
|
-
// the behavior multiplication/preferences system processes behaviors,
|
|
88
|
-
// so it has the final say on what behaviors are enabled/disabled.
|
|
89
|
-
override: {
|
|
90
|
-
provides: ['uniqueLookupControl'],
|
|
91
|
-
callback(behavior, [_resource, unique]) {
|
|
92
|
-
if (disableAllUniqueLookups) {
|
|
93
|
-
// Disable ALL unique QUERY lookups - users must use filters
|
|
94
|
-
// But KEEP primary key mutations (updateX, deleteX)
|
|
95
|
-
if (unique.isPrimary) {
|
|
96
|
-
// Primary key: only disable query lookups, keep mutations
|
|
97
|
-
return [behavior, '-single'];
|
|
98
|
-
}
|
|
99
|
-
// Non-primary-key: disable everything (queries and mutations)
|
|
100
|
-
return [
|
|
101
|
-
behavior,
|
|
102
|
-
'-single',
|
|
103
|
-
'-constraint:resource:update',
|
|
104
|
-
'-constraint:resource:delete',
|
|
105
|
-
];
|
|
106
|
-
}
|
|
107
|
-
// Only allow primary key lookups (both queries and mutations)
|
|
108
|
-
if (!unique.isPrimary) {
|
|
109
|
-
// Disable non-primary-key unique constraint lookups for queries and mutations
|
|
110
|
-
return [
|
|
111
|
-
behavior,
|
|
112
|
-
'-single',
|
|
113
|
-
'-constraint:resource:update',
|
|
114
|
-
'-constraint:resource:delete',
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
return behavior;
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
// Default plugin instance (primary key only)
|
|
126
|
-
exports.PrimaryKeyOnlyPlugin = createUniqueLookupPlugin({
|
|
127
|
-
disableAllUniqueLookups: false,
|
|
128
|
-
});
|
|
129
|
-
// Plugin that disables ALL unique lookups
|
|
130
|
-
exports.NoUniqueLookupPlugin = createUniqueLookupPlugin({
|
|
131
|
-
disableAllUniqueLookups: true,
|
|
132
|
-
});
|
|
133
|
-
/**
|
|
134
|
-
* Preset that keeps only primary key lookups.
|
|
135
|
-
* Use this in your main preset's `extends` array.
|
|
136
|
-
*/
|
|
137
|
-
exports.PrimaryKeyOnlyPreset = {
|
|
138
|
-
plugins: [exports.PrimaryKeyOnlyPlugin],
|
|
139
|
-
};
|
|
140
|
-
/**
|
|
141
|
-
* Preset that disables ALL unique lookups (including primary keys).
|
|
142
|
-
* Users must use collection queries with filters instead.
|
|
143
|
-
* Use this in your main preset's `extends` array.
|
|
144
|
-
*/
|
|
145
|
-
exports.NoUniqueLookupPreset = {
|
|
146
|
-
plugins: [exports.NoUniqueLookupPlugin],
|
|
147
|
-
};
|