graphile-settings 4.18.3 → 4.18.4
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/plugins/custom-inflector.d.ts +0 -2
- package/esm/plugins/custom-inflector.js +0 -3
- package/esm/plugins/enable-all-filter-columns.d.ts +11 -10
- package/esm/plugins/enable-all-filter-columns.js +17 -15
- package/esm/plugins/index.d.ts +1 -1
- package/esm/plugins/index.js +1 -1
- package/esm/presets/constructive-preset.d.ts +0 -4
- package/esm/presets/constructive-preset.js +0 -4
- package/package.json +11 -11
- package/plugins/custom-inflector.d.ts +0 -2
- package/plugins/custom-inflector.js +1 -4
- package/plugins/enable-all-filter-columns.d.ts +11 -10
- package/plugins/enable-all-filter-columns.js +17 -15
- package/plugins/index.d.ts +1 -1
- package/plugins/index.js +1 -3
- package/presets/constructive-preset.d.ts +0 -4
- package/presets/constructive-preset.js +0 -4
|
@@ -5,5 +5,3 @@ export declare const InflektPlugin: GraphileConfig.Plugin;
|
|
|
5
5
|
* Use this in your main preset's `extends` array.
|
|
6
6
|
*/
|
|
7
7
|
export declare const InflektPreset: GraphileConfig.Preset;
|
|
8
|
-
export declare const CustomInflectorPlugin: GraphileConfig.Plugin;
|
|
9
|
-
export declare const CustomInflectorPreset: GraphileConfig.Preset;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { GraphileConfig } from 'graphile-config';
|
|
2
2
|
/**
|
|
3
|
-
* EnableAllFilterColumnsPlugin - Enables filtering on ALL columns, not just indexed ones.
|
|
3
|
+
* EnableAllFilterColumnsPlugin - Enables filtering and ordering on ALL columns, not just indexed ones.
|
|
4
4
|
*
|
|
5
5
|
* WHY THIS EXISTS:
|
|
6
|
-
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering to only indexed columns
|
|
7
|
-
* by default. This is a performance optimization - filtering on non-indexed columns can
|
|
6
|
+
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering and ordering to only indexed columns
|
|
7
|
+
* by default. This is a performance optimization - filtering/ordering on non-indexed columns can
|
|
8
8
|
* cause slow table scans. However, for development and flexibility, we want to allow
|
|
9
|
-
* filtering on all columns and let developers/DBAs decide which columns need indexes.
|
|
9
|
+
* filtering and ordering on all columns and let developers/DBAs decide which columns need indexes.
|
|
10
10
|
*
|
|
11
11
|
* SOURCE CODE REFERENCE:
|
|
12
12
|
* PgIndexBehaviorsPlugin marks non-indexed columns with `extensions.isIndexed = false`
|
|
13
|
-
* and then adds `-filterBy`
|
|
13
|
+
* and then adds `-filterBy` and `-orderBy` behaviors to remove them from filters and ordering:
|
|
14
14
|
* https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgIndexBehaviorsPlugin.ts
|
|
15
15
|
*
|
|
16
16
|
* The relevant v5 code (from PgIndexBehaviorsPlugin):
|
|
@@ -24,7 +24,7 @@ import type { GraphileConfig } from 'graphile-config';
|
|
|
24
24
|
* const newBehavior = [behavior];
|
|
25
25
|
* const attr = codec.attributes[attributeName];
|
|
26
26
|
* if (attr.extensions?.isIndexed === false) {
|
|
27
|
-
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy!
|
|
27
|
+
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy AND orderBy!
|
|
28
28
|
* }
|
|
29
29
|
* return newBehavior;
|
|
30
30
|
* },
|
|
@@ -35,15 +35,16 @@ import type { GraphileConfig } from 'graphile-config';
|
|
|
35
35
|
*
|
|
36
36
|
* OUR FIX:
|
|
37
37
|
* We add a behavior callback that runs AFTER PgIndexBehaviorsPlugin's "postInferred" phase
|
|
38
|
-
* and adds `+attribute:filterBy` back to ALL columns, regardless of index status.
|
|
38
|
+
* and adds `+attribute:filterBy` and `+attribute:orderBy` back to ALL columns, regardless of index status.
|
|
39
39
|
*
|
|
40
40
|
* This means:
|
|
41
41
|
* - All columns will appear in the connection filter's filter argument
|
|
42
|
-
* -
|
|
43
|
-
* -
|
|
42
|
+
* - All columns will appear in the connection's orderBy enum
|
|
43
|
+
* - Developers can filter and sort by any column
|
|
44
|
+
* - It's the developer's/DBA's responsibility to add indexes for frequently filtered/sorted columns
|
|
44
45
|
*
|
|
45
46
|
* PERFORMANCE WARNING:
|
|
46
|
-
* Filtering on non-indexed columns can cause full table scans, which may be slow on large
|
|
47
|
+
* Filtering or ordering on non-indexed columns can cause full table scans, which may be slow on large
|
|
47
48
|
* tables. Monitor your query performance and add indexes as needed. You can check which
|
|
48
49
|
* columns are indexed by querying pg_indexes or using EXPLAIN ANALYZE on your queries.
|
|
49
50
|
*
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* EnableAllFilterColumnsPlugin - Enables filtering on ALL columns, not just indexed ones.
|
|
2
|
+
* EnableAllFilterColumnsPlugin - Enables filtering and ordering on ALL columns, not just indexed ones.
|
|
3
3
|
*
|
|
4
4
|
* WHY THIS EXISTS:
|
|
5
|
-
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering to only indexed columns
|
|
6
|
-
* by default. This is a performance optimization - filtering on non-indexed columns can
|
|
5
|
+
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering and ordering to only indexed columns
|
|
6
|
+
* by default. This is a performance optimization - filtering/ordering on non-indexed columns can
|
|
7
7
|
* cause slow table scans. However, for development and flexibility, we want to allow
|
|
8
|
-
* filtering on all columns and let developers/DBAs decide which columns need indexes.
|
|
8
|
+
* filtering and ordering on all columns and let developers/DBAs decide which columns need indexes.
|
|
9
9
|
*
|
|
10
10
|
* SOURCE CODE REFERENCE:
|
|
11
11
|
* PgIndexBehaviorsPlugin marks non-indexed columns with `extensions.isIndexed = false`
|
|
12
|
-
* and then adds `-filterBy`
|
|
12
|
+
* and then adds `-filterBy` and `-orderBy` behaviors to remove them from filters and ordering:
|
|
13
13
|
* https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgIndexBehaviorsPlugin.ts
|
|
14
14
|
*
|
|
15
15
|
* The relevant v5 code (from PgIndexBehaviorsPlugin):
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* const newBehavior = [behavior];
|
|
24
24
|
* const attr = codec.attributes[attributeName];
|
|
25
25
|
* if (attr.extensions?.isIndexed === false) {
|
|
26
|
-
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy!
|
|
26
|
+
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy AND orderBy!
|
|
27
27
|
* }
|
|
28
28
|
* return newBehavior;
|
|
29
29
|
* },
|
|
@@ -34,15 +34,16 @@
|
|
|
34
34
|
*
|
|
35
35
|
* OUR FIX:
|
|
36
36
|
* We add a behavior callback that runs AFTER PgIndexBehaviorsPlugin's "postInferred" phase
|
|
37
|
-
* and adds `+attribute:filterBy` back to ALL columns, regardless of index status.
|
|
37
|
+
* and adds `+attribute:filterBy` and `+attribute:orderBy` back to ALL columns, regardless of index status.
|
|
38
38
|
*
|
|
39
39
|
* This means:
|
|
40
40
|
* - All columns will appear in the connection filter's filter argument
|
|
41
|
-
* -
|
|
42
|
-
* -
|
|
41
|
+
* - All columns will appear in the connection's orderBy enum
|
|
42
|
+
* - Developers can filter and sort by any column
|
|
43
|
+
* - It's the developer's/DBA's responsibility to add indexes for frequently filtered/sorted columns
|
|
43
44
|
*
|
|
44
45
|
* PERFORMANCE WARNING:
|
|
45
|
-
* Filtering on non-indexed columns can cause full table scans, which may be slow on large
|
|
46
|
+
* Filtering or ordering on non-indexed columns can cause full table scans, which may be slow on large
|
|
46
47
|
* tables. Monitor your query performance and add indexes as needed. You can check which
|
|
47
48
|
* columns are indexed by querying pg_indexes or using EXPLAIN ANALYZE on your queries.
|
|
48
49
|
*
|
|
@@ -54,22 +55,23 @@
|
|
|
54
55
|
export const EnableAllFilterColumnsPlugin = {
|
|
55
56
|
name: 'EnableAllFilterColumnsPlugin',
|
|
56
57
|
version: '1.0.0',
|
|
57
|
-
description: 'Enables filtering on all columns, not just indexed ones',
|
|
58
|
+
description: 'Enables filtering and ordering on all columns, not just indexed ones',
|
|
58
59
|
schema: {
|
|
59
60
|
entityBehavior: {
|
|
60
61
|
pgCodecAttribute: {
|
|
61
62
|
/**
|
|
62
63
|
* This callback runs in the "inferred" phase AFTER PgIndexBehaviorsPlugin's
|
|
63
|
-
* "postInferred" phase. It adds `filterBy` back to ALL columns,
|
|
64
|
-
* the `-filterBy` that PgIndexBehaviorsPlugin adds
|
|
64
|
+
* "postInferred" phase. It adds `filterBy` and `orderBy` back to ALL columns,
|
|
65
|
+
* overriding the `-filterBy` and `-orderBy` that PgIndexBehaviorsPlugin adds
|
|
66
|
+
* to non-indexed columns.
|
|
65
67
|
*/
|
|
66
68
|
inferred: {
|
|
67
69
|
after: ['postInferred'],
|
|
68
70
|
provides: ['enableAllFilters'],
|
|
69
71
|
callback(behavior) {
|
|
70
|
-
// Add filterBy to override
|
|
72
|
+
// Add filterBy and orderBy to override PgIndexBehaviorsPlugin restrictions
|
|
71
73
|
// The behavior system will resolve conflicts, with later additions winning
|
|
72
|
-
return [behavior, 'filterBy'];
|
|
74
|
+
return [behavior, 'filterBy', 'orderBy'];
|
|
73
75
|
},
|
|
74
76
|
},
|
|
75
77
|
},
|
package/esm/plugins/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This module exports all custom plugins (consolidated from graphile-misc-plugins).
|
|
5
5
|
*/
|
|
6
6
|
export { MinimalPreset } from './minimal-preset';
|
|
7
|
-
export { InflektPlugin, InflektPreset,
|
|
7
|
+
export { InflektPlugin, InflektPreset, } from './custom-inflector';
|
|
8
8
|
export { ConflictDetectorPlugin, ConflictDetectorPreset, } from './conflict-detector';
|
|
9
9
|
export { InflectorLoggerPlugin, InflectorLoggerPreset, } from './inflector-logger';
|
|
10
10
|
export { EnableAllFilterColumnsPlugin, EnableAllFilterColumnsPreset, } from './enable-all-filter-columns';
|
package/esm/plugins/index.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// Minimal preset - PostGraphile without Node/Relay features
|
|
7
7
|
export { MinimalPreset } from './minimal-preset';
|
|
8
8
|
// Custom inflector using inflekt library
|
|
9
|
-
export { InflektPlugin, InflektPreset,
|
|
9
|
+
export { InflektPlugin, InflektPreset, } from './custom-inflector';
|
|
10
10
|
// Conflict detector for multi-schema setups
|
|
11
11
|
export { ConflictDetectorPlugin, ConflictDetectorPreset, } from './conflict-detector';
|
|
12
12
|
// Inflector logger for debugging
|
|
@@ -26,10 +26,6 @@ import type { GraphileConfig } from 'graphile-config';
|
|
|
26
26
|
* - pg_trgm fuzzy matching (similarTo/wordSimilarTo on text columns, similarity score fields,
|
|
27
27
|
* orderBy similarity — zero config, typo-tolerant)
|
|
28
28
|
*
|
|
29
|
-
* DEPRECATED:
|
|
30
|
-
* - The `condition` argument has been removed. All filtering lives under `filter`.
|
|
31
|
-
* PgConditionArgumentPlugin and PgConditionCustomFieldsPlugin are disabled.
|
|
32
|
-
*
|
|
33
29
|
* RELATION FILTERS:
|
|
34
30
|
* - Enabled via connectionFilterRelations: true
|
|
35
31
|
* - Forward: filter child by parent (e.g. allOrders(filter: { clientByClientId: { name: { startsWith: "Acme" } } }))
|
|
@@ -32,10 +32,6 @@ import { constructiveUploadFieldDefinitions } from '../upload-resolver';
|
|
|
32
32
|
* - pg_trgm fuzzy matching (similarTo/wordSimilarTo on text columns, similarity score fields,
|
|
33
33
|
* orderBy similarity — zero config, typo-tolerant)
|
|
34
34
|
*
|
|
35
|
-
* DEPRECATED:
|
|
36
|
-
* - The `condition` argument has been removed. All filtering lives under `filter`.
|
|
37
|
-
* PgConditionArgumentPlugin and PgConditionCustomFieldsPlugin are disabled.
|
|
38
|
-
*
|
|
39
35
|
* RELATION FILTERS:
|
|
40
36
|
* - Enabled via connectionFilterRelations: true
|
|
41
37
|
* - Forward: filter child by parent (e.g. allOrders(filter: { clientByClientId: { name: { startsWith: "Acme" } } }))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-settings",
|
|
3
|
-
"version": "4.18.
|
|
3
|
+
"version": "4.18.4",
|
|
4
4
|
"author": "Constructive <developers@constructive.io>",
|
|
5
5
|
"description": "graphile settings",
|
|
6
6
|
"main": "index.js",
|
|
@@ -29,15 +29,15 @@
|
|
|
29
29
|
"test:watch": "jest --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@constructive-io/graphql-env": "^3.5.
|
|
33
|
-
"@constructive-io/graphql-types": "^3.4.
|
|
34
|
-
"@constructive-io/s3-streamer": "^2.17.
|
|
32
|
+
"@constructive-io/graphql-env": "^3.5.3",
|
|
33
|
+
"@constructive-io/graphql-types": "^3.4.3",
|
|
34
|
+
"@constructive-io/s3-streamer": "^2.17.3",
|
|
35
35
|
"@constructive-io/upload-names": "^2.10.2",
|
|
36
36
|
"@dataplan/json": "1.0.0",
|
|
37
37
|
"@dataplan/pg": "1.0.0",
|
|
38
38
|
"@graphile-contrib/pg-many-to-many": "2.0.0-rc.2",
|
|
39
39
|
"@pgpmjs/logger": "^2.5.2",
|
|
40
|
-
"@pgpmjs/types": "^2.20.
|
|
40
|
+
"@pgpmjs/types": "^2.20.3",
|
|
41
41
|
"@pgsql/quotes": "^17.1.0",
|
|
42
42
|
"cors": "^2.8.6",
|
|
43
43
|
"express": "^5.2.1",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"graphile-build": "5.0.0",
|
|
47
47
|
"graphile-build-pg": "5.0.0",
|
|
48
48
|
"graphile-config": "1.0.0",
|
|
49
|
-
"graphile-connection-filter": "^1.3.
|
|
50
|
-
"graphile-postgis": "^2.9.
|
|
51
|
-
"graphile-search": "^1.5.
|
|
49
|
+
"graphile-connection-filter": "^1.3.5",
|
|
50
|
+
"graphile-postgis": "^2.9.6",
|
|
51
|
+
"graphile-search": "^1.5.5",
|
|
52
52
|
"graphile-sql-expression-validator": "^2.6.2",
|
|
53
53
|
"graphile-upload-plugin": "^2.5.2",
|
|
54
54
|
"graphile-utils": "5.0.0",
|
|
@@ -67,10 +67,10 @@
|
|
|
67
67
|
"@types/express": "^5.0.6",
|
|
68
68
|
"@types/pg": "^8.18.0",
|
|
69
69
|
"@types/request-ip": "^0.0.41",
|
|
70
|
-
"graphile-test": "^4.7.
|
|
70
|
+
"graphile-test": "^4.7.5",
|
|
71
71
|
"makage": "^0.3.0",
|
|
72
72
|
"nodemon": "^3.1.14",
|
|
73
|
-
"pgsql-test": "^4.7.
|
|
73
|
+
"pgsql-test": "^4.7.5",
|
|
74
74
|
"ts-node": "^10.9.2"
|
|
75
75
|
},
|
|
76
76
|
"keywords": [
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"constructive",
|
|
81
81
|
"graphql"
|
|
82
82
|
],
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "d0d8f5ca5828ad3efba5f607bc699a8d520e4603"
|
|
84
84
|
}
|
|
@@ -5,5 +5,3 @@ export declare const InflektPlugin: GraphileConfig.Plugin;
|
|
|
5
5
|
* Use this in your main preset's `extends` array.
|
|
6
6
|
*/
|
|
7
7
|
export declare const InflektPreset: GraphileConfig.Preset;
|
|
8
|
-
export declare const CustomInflectorPlugin: GraphileConfig.Plugin;
|
|
9
|
-
export declare const CustomInflectorPreset: GraphileConfig.Preset;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.InflektPreset = exports.InflektPlugin = void 0;
|
|
4
4
|
const inflekt_1 = require("inflekt");
|
|
5
5
|
/**
|
|
6
6
|
* Custom inflector plugin for Constructive using the inflekt library.
|
|
@@ -392,6 +392,3 @@ exports.InflektPlugin = {
|
|
|
392
392
|
exports.InflektPreset = {
|
|
393
393
|
plugins: [exports.InflektPlugin],
|
|
394
394
|
};
|
|
395
|
-
// Re-export for backwards compatibility
|
|
396
|
-
exports.CustomInflectorPlugin = exports.InflektPlugin;
|
|
397
|
-
exports.CustomInflectorPreset = exports.InflektPreset;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { GraphileConfig } from 'graphile-config';
|
|
2
2
|
/**
|
|
3
|
-
* EnableAllFilterColumnsPlugin - Enables filtering on ALL columns, not just indexed ones.
|
|
3
|
+
* EnableAllFilterColumnsPlugin - Enables filtering and ordering on ALL columns, not just indexed ones.
|
|
4
4
|
*
|
|
5
5
|
* WHY THIS EXISTS:
|
|
6
|
-
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering to only indexed columns
|
|
7
|
-
* by default. This is a performance optimization - filtering on non-indexed columns can
|
|
6
|
+
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering and ordering to only indexed columns
|
|
7
|
+
* by default. This is a performance optimization - filtering/ordering on non-indexed columns can
|
|
8
8
|
* cause slow table scans. However, for development and flexibility, we want to allow
|
|
9
|
-
* filtering on all columns and let developers/DBAs decide which columns need indexes.
|
|
9
|
+
* filtering and ordering on all columns and let developers/DBAs decide which columns need indexes.
|
|
10
10
|
*
|
|
11
11
|
* SOURCE CODE REFERENCE:
|
|
12
12
|
* PgIndexBehaviorsPlugin marks non-indexed columns with `extensions.isIndexed = false`
|
|
13
|
-
* and then adds `-filterBy`
|
|
13
|
+
* and then adds `-filterBy` and `-orderBy` behaviors to remove them from filters and ordering:
|
|
14
14
|
* https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgIndexBehaviorsPlugin.ts
|
|
15
15
|
*
|
|
16
16
|
* The relevant v5 code (from PgIndexBehaviorsPlugin):
|
|
@@ -24,7 +24,7 @@ import type { GraphileConfig } from 'graphile-config';
|
|
|
24
24
|
* const newBehavior = [behavior];
|
|
25
25
|
* const attr = codec.attributes[attributeName];
|
|
26
26
|
* if (attr.extensions?.isIndexed === false) {
|
|
27
|
-
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy!
|
|
27
|
+
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy AND orderBy!
|
|
28
28
|
* }
|
|
29
29
|
* return newBehavior;
|
|
30
30
|
* },
|
|
@@ -35,15 +35,16 @@ import type { GraphileConfig } from 'graphile-config';
|
|
|
35
35
|
*
|
|
36
36
|
* OUR FIX:
|
|
37
37
|
* We add a behavior callback that runs AFTER PgIndexBehaviorsPlugin's "postInferred" phase
|
|
38
|
-
* and adds `+attribute:filterBy` back to ALL columns, regardless of index status.
|
|
38
|
+
* and adds `+attribute:filterBy` and `+attribute:orderBy` back to ALL columns, regardless of index status.
|
|
39
39
|
*
|
|
40
40
|
* This means:
|
|
41
41
|
* - All columns will appear in the connection filter's filter argument
|
|
42
|
-
* -
|
|
43
|
-
* -
|
|
42
|
+
* - All columns will appear in the connection's orderBy enum
|
|
43
|
+
* - Developers can filter and sort by any column
|
|
44
|
+
* - It's the developer's/DBA's responsibility to add indexes for frequently filtered/sorted columns
|
|
44
45
|
*
|
|
45
46
|
* PERFORMANCE WARNING:
|
|
46
|
-
* Filtering on non-indexed columns can cause full table scans, which may be slow on large
|
|
47
|
+
* Filtering or ordering on non-indexed columns can cause full table scans, which may be slow on large
|
|
47
48
|
* tables. Monitor your query performance and add indexes as needed. You can check which
|
|
48
49
|
* columns are indexed by querying pg_indexes or using EXPLAIN ANALYZE on your queries.
|
|
49
50
|
*
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnableAllFilterColumnsPreset = exports.EnableAllFilterColumnsPlugin = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* EnableAllFilterColumnsPlugin - Enables filtering on ALL columns, not just indexed ones.
|
|
5
|
+
* EnableAllFilterColumnsPlugin - Enables filtering and ordering on ALL columns, not just indexed ones.
|
|
6
6
|
*
|
|
7
7
|
* WHY THIS EXISTS:
|
|
8
|
-
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering to only indexed columns
|
|
9
|
-
* by default. This is a performance optimization - filtering on non-indexed columns can
|
|
8
|
+
* PostGraphile v5's `PgIndexBehaviorsPlugin` restricts filtering and ordering to only indexed columns
|
|
9
|
+
* by default. This is a performance optimization - filtering/ordering on non-indexed columns can
|
|
10
10
|
* cause slow table scans. However, for development and flexibility, we want to allow
|
|
11
|
-
* filtering on all columns and let developers/DBAs decide which columns need indexes.
|
|
11
|
+
* filtering and ordering on all columns and let developers/DBAs decide which columns need indexes.
|
|
12
12
|
*
|
|
13
13
|
* SOURCE CODE REFERENCE:
|
|
14
14
|
* PgIndexBehaviorsPlugin marks non-indexed columns with `extensions.isIndexed = false`
|
|
15
|
-
* and then adds `-filterBy`
|
|
15
|
+
* and then adds `-filterBy` and `-orderBy` behaviors to remove them from filters and ordering:
|
|
16
16
|
* https://github.com/graphile/crystal/blob/924b2515c6bd30e5905ac1419a25244b40c8bb4d/graphile-build/graphile-build-pg/src/plugins/PgIndexBehaviorsPlugin.ts
|
|
17
17
|
*
|
|
18
18
|
* The relevant v5 code (from PgIndexBehaviorsPlugin):
|
|
@@ -26,7 +26,7 @@ exports.EnableAllFilterColumnsPreset = exports.EnableAllFilterColumnsPlugin = vo
|
|
|
26
26
|
* const newBehavior = [behavior];
|
|
27
27
|
* const attr = codec.attributes[attributeName];
|
|
28
28
|
* if (attr.extensions?.isIndexed === false) {
|
|
29
|
-
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy!
|
|
29
|
+
* newBehavior.push("-filterBy", "-orderBy"); // <-- This removes filterBy AND orderBy!
|
|
30
30
|
* }
|
|
31
31
|
* return newBehavior;
|
|
32
32
|
* },
|
|
@@ -37,15 +37,16 @@ exports.EnableAllFilterColumnsPreset = exports.EnableAllFilterColumnsPlugin = vo
|
|
|
37
37
|
*
|
|
38
38
|
* OUR FIX:
|
|
39
39
|
* We add a behavior callback that runs AFTER PgIndexBehaviorsPlugin's "postInferred" phase
|
|
40
|
-
* and adds `+attribute:filterBy` back to ALL columns, regardless of index status.
|
|
40
|
+
* and adds `+attribute:filterBy` and `+attribute:orderBy` back to ALL columns, regardless of index status.
|
|
41
41
|
*
|
|
42
42
|
* This means:
|
|
43
43
|
* - All columns will appear in the connection filter's filter argument
|
|
44
|
-
* -
|
|
45
|
-
* -
|
|
44
|
+
* - All columns will appear in the connection's orderBy enum
|
|
45
|
+
* - Developers can filter and sort by any column
|
|
46
|
+
* - It's the developer's/DBA's responsibility to add indexes for frequently filtered/sorted columns
|
|
46
47
|
*
|
|
47
48
|
* PERFORMANCE WARNING:
|
|
48
|
-
* Filtering on non-indexed columns can cause full table scans, which may be slow on large
|
|
49
|
+
* Filtering or ordering on non-indexed columns can cause full table scans, which may be slow on large
|
|
49
50
|
* tables. Monitor your query performance and add indexes as needed. You can check which
|
|
50
51
|
* columns are indexed by querying pg_indexes or using EXPLAIN ANALYZE on your queries.
|
|
51
52
|
*
|
|
@@ -57,22 +58,23 @@ exports.EnableAllFilterColumnsPreset = exports.EnableAllFilterColumnsPlugin = vo
|
|
|
57
58
|
exports.EnableAllFilterColumnsPlugin = {
|
|
58
59
|
name: 'EnableAllFilterColumnsPlugin',
|
|
59
60
|
version: '1.0.0',
|
|
60
|
-
description: 'Enables filtering on all columns, not just indexed ones',
|
|
61
|
+
description: 'Enables filtering and ordering on all columns, not just indexed ones',
|
|
61
62
|
schema: {
|
|
62
63
|
entityBehavior: {
|
|
63
64
|
pgCodecAttribute: {
|
|
64
65
|
/**
|
|
65
66
|
* This callback runs in the "inferred" phase AFTER PgIndexBehaviorsPlugin's
|
|
66
|
-
* "postInferred" phase. It adds `filterBy` back to ALL columns,
|
|
67
|
-
* the `-filterBy` that PgIndexBehaviorsPlugin adds
|
|
67
|
+
* "postInferred" phase. It adds `filterBy` and `orderBy` back to ALL columns,
|
|
68
|
+
* overriding the `-filterBy` and `-orderBy` that PgIndexBehaviorsPlugin adds
|
|
69
|
+
* to non-indexed columns.
|
|
68
70
|
*/
|
|
69
71
|
inferred: {
|
|
70
72
|
after: ['postInferred'],
|
|
71
73
|
provides: ['enableAllFilters'],
|
|
72
74
|
callback(behavior) {
|
|
73
|
-
// Add filterBy to override
|
|
75
|
+
// Add filterBy and orderBy to override PgIndexBehaviorsPlugin restrictions
|
|
74
76
|
// The behavior system will resolve conflicts, with later additions winning
|
|
75
|
-
return [behavior, 'filterBy'];
|
|
77
|
+
return [behavior, 'filterBy', 'orderBy'];
|
|
76
78
|
},
|
|
77
79
|
},
|
|
78
80
|
},
|
package/plugins/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* This module exports all custom plugins (consolidated from graphile-misc-plugins).
|
|
5
5
|
*/
|
|
6
6
|
export { MinimalPreset } from './minimal-preset';
|
|
7
|
-
export { InflektPlugin, InflektPreset,
|
|
7
|
+
export { InflektPlugin, InflektPreset, } from './custom-inflector';
|
|
8
8
|
export { ConflictDetectorPlugin, ConflictDetectorPreset, } from './conflict-detector';
|
|
9
9
|
export { InflectorLoggerPlugin, InflectorLoggerPreset, } from './inflector-logger';
|
|
10
10
|
export { EnableAllFilterColumnsPlugin, EnableAllFilterColumnsPreset, } from './enable-all-filter-columns';
|
package/plugins/index.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* This module exports all custom plugins (consolidated from graphile-misc-plugins).
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
-
exports.createTrgmOperatorFactories = exports.createMatchesOperatorFactory = exports.createPgvectorAdapter = exports.createTrgmAdapter = exports.createBm25Adapter = exports.createTsvectorAdapter = exports.VectorCodecPreset = exports.VectorCodecPlugin = exports.bm25IndexStore = exports.Bm25CodecPreset = exports.Bm25CodecPlugin = exports.createTsvectorCodecPlugin = exports.TsvectorCodecPreset = exports.TsvectorCodecPlugin = exports.UnifiedSearchPreset = exports.createUnifiedSearchPlugin = exports.RequiredInputPreset = exports.RequiredInputPlugin = exports._cachedTablesMeta = exports._buildFieldMeta = exports._pgTypeToGqlType = exports.PublicKeySignature = exports.PgTypeMappingsPreset = exports.PgTypeMappingsPlugin = exports.MetaSchemaPreset = exports.MetaSchemaPlugin = exports.NoUniqueLookupPreset = exports.PrimaryKeyOnlyPreset = exports.NoUniqueLookupPlugin = exports.PrimaryKeyOnlyPlugin = exports.createUniqueLookupPlugin = exports.ManyToManyOptInPreset = exports.ManyToManyOptInPlugin = exports.EnableAllFilterColumnsPreset = exports.EnableAllFilterColumnsPlugin = exports.InflectorLoggerPreset = exports.InflectorLoggerPlugin = exports.ConflictDetectorPreset = exports.ConflictDetectorPlugin = exports.
|
|
8
|
+
exports.createTrgmOperatorFactories = exports.createMatchesOperatorFactory = exports.createPgvectorAdapter = exports.createTrgmAdapter = exports.createBm25Adapter = exports.createTsvectorAdapter = exports.VectorCodecPreset = exports.VectorCodecPlugin = exports.bm25IndexStore = exports.Bm25CodecPreset = exports.Bm25CodecPlugin = exports.createTsvectorCodecPlugin = exports.TsvectorCodecPreset = exports.TsvectorCodecPlugin = exports.UnifiedSearchPreset = exports.createUnifiedSearchPlugin = exports.RequiredInputPreset = exports.RequiredInputPlugin = exports._cachedTablesMeta = exports._buildFieldMeta = exports._pgTypeToGqlType = exports.PublicKeySignature = exports.PgTypeMappingsPreset = exports.PgTypeMappingsPlugin = exports.MetaSchemaPreset = exports.MetaSchemaPlugin = exports.NoUniqueLookupPreset = exports.PrimaryKeyOnlyPreset = exports.NoUniqueLookupPlugin = exports.PrimaryKeyOnlyPlugin = exports.createUniqueLookupPlugin = exports.ManyToManyOptInPreset = exports.ManyToManyOptInPlugin = exports.EnableAllFilterColumnsPreset = exports.EnableAllFilterColumnsPlugin = exports.InflectorLoggerPreset = exports.InflectorLoggerPlugin = exports.ConflictDetectorPreset = exports.ConflictDetectorPlugin = exports.InflektPreset = exports.InflektPlugin = exports.MinimalPreset = void 0;
|
|
9
9
|
// Minimal preset - PostGraphile without Node/Relay features
|
|
10
10
|
var minimal_preset_1 = require("./minimal-preset");
|
|
11
11
|
Object.defineProperty(exports, "MinimalPreset", { enumerable: true, get: function () { return minimal_preset_1.MinimalPreset; } });
|
|
@@ -13,8 +13,6 @@ Object.defineProperty(exports, "MinimalPreset", { enumerable: true, get: functio
|
|
|
13
13
|
var custom_inflector_1 = require("./custom-inflector");
|
|
14
14
|
Object.defineProperty(exports, "InflektPlugin", { enumerable: true, get: function () { return custom_inflector_1.InflektPlugin; } });
|
|
15
15
|
Object.defineProperty(exports, "InflektPreset", { enumerable: true, get: function () { return custom_inflector_1.InflektPreset; } });
|
|
16
|
-
Object.defineProperty(exports, "CustomInflectorPlugin", { enumerable: true, get: function () { return custom_inflector_1.CustomInflectorPlugin; } });
|
|
17
|
-
Object.defineProperty(exports, "CustomInflectorPreset", { enumerable: true, get: function () { return custom_inflector_1.CustomInflectorPreset; } });
|
|
18
16
|
// Conflict detector for multi-schema setups
|
|
19
17
|
var conflict_detector_1 = require("./conflict-detector");
|
|
20
18
|
Object.defineProperty(exports, "ConflictDetectorPlugin", { enumerable: true, get: function () { return conflict_detector_1.ConflictDetectorPlugin; } });
|
|
@@ -26,10 +26,6 @@ import type { GraphileConfig } from 'graphile-config';
|
|
|
26
26
|
* - pg_trgm fuzzy matching (similarTo/wordSimilarTo on text columns, similarity score fields,
|
|
27
27
|
* orderBy similarity — zero config, typo-tolerant)
|
|
28
28
|
*
|
|
29
|
-
* DEPRECATED:
|
|
30
|
-
* - The `condition` argument has been removed. All filtering lives under `filter`.
|
|
31
|
-
* PgConditionArgumentPlugin and PgConditionCustomFieldsPlugin are disabled.
|
|
32
|
-
*
|
|
33
29
|
* RELATION FILTERS:
|
|
34
30
|
* - Enabled via connectionFilterRelations: true
|
|
35
31
|
* - Forward: filter child by parent (e.g. allOrders(filter: { clientByClientId: { name: { startsWith: "Acme" } } }))
|
|
@@ -35,10 +35,6 @@ const upload_resolver_1 = require("../upload-resolver");
|
|
|
35
35
|
* - pg_trgm fuzzy matching (similarTo/wordSimilarTo on text columns, similarity score fields,
|
|
36
36
|
* orderBy similarity — zero config, typo-tolerant)
|
|
37
37
|
*
|
|
38
|
-
* DEPRECATED:
|
|
39
|
-
* - The `condition` argument has been removed. All filtering lives under `filter`.
|
|
40
|
-
* PgConditionArgumentPlugin and PgConditionCustomFieldsPlugin are disabled.
|
|
41
|
-
*
|
|
42
38
|
* RELATION FILTERS:
|
|
43
39
|
* - Enabled via connectionFilterRelations: true
|
|
44
40
|
* - Forward: filter child by parent (e.g. allOrders(filter: { clientByClientId: { name: { startsWith: "Acme" } } }))
|