Skip to content

Commit 6246875

Browse files
committed
Register behavior and note it's actually filterBy not filter
1 parent a549c3a commit 6246875

4 files changed

Lines changed: 48 additions & 7 deletions

src/PgConnectionArgFilterAttributesPlugin.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { version } = require("../package.json");
55
declare global {
66
namespace GraphileBuild {
77
interface BehaviorStrings {
8-
"attribute:filter": true;
8+
"attribute:filterBy": true;
99
}
1010
}
1111
}
@@ -15,8 +15,21 @@ export const PgConnectionArgFilterAttributesPlugin: GraphileConfig.Plugin = {
1515
version,
1616

1717
schema: {
18+
behaviorRegistry: {
19+
add: {
20+
"attribute:filterBy": {
21+
description: "Can we filter by this attribute",
22+
entities: ["pgCodecAttribute"],
23+
},
24+
filterBy: {
25+
description: "Can we filter by this attribute",
26+
entities: ["pgCodecAttribute"],
27+
},
28+
},
29+
},
30+
1831
entityBehavior: {
19-
pgCodecAttribute: "filter",
32+
pgCodecAttribute: "filterBy",
2033
},
2134

2235
hooks: {
@@ -44,7 +57,7 @@ export const PgConnectionArgFilterAttributesPlugin: GraphileConfig.Plugin = {
4457
if (
4558
!build.behavior.pgCodecAttributeMatches(
4659
[codec, attributeName],
47-
"attribute:filter"
60+
"attribute:filterBy"
4861
)
4962
) {
5063
continue;

src/PgConnectionArgFilterBackwardRelationsPlugin.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export const PgConnectionArgFilterBackwardRelationsPlugin: GraphileConfig.Plugin
5959

6060
schema: {
6161
entityBehavior: {
62-
pgCodecRelation: "filter",
62+
pgCodecRelation: "filterBy",
6363
},
6464

6565
hooks: {
@@ -154,7 +154,9 @@ export const PgConnectionArgFilterBackwardRelationsPlugin: GraphileConfig.Plugin
154154
const foreignTable = relation.remoteResource; // Deliberate shadowing
155155

156156
// Used to use 'read' behavior too
157-
if (!build.behavior.pgCodecRelationMatches(relation, "filter")) {
157+
if (
158+
!build.behavior.pgCodecRelationMatches(relation, "filterBy")
159+
) {
158160
continue;
159161
}
160162

src/PgConnectionArgFilterComputedAttributesPlugin.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,29 @@ import type { FieldArgs } from "grafast";
77

88
const { version } = require("../package.json");
99

10+
declare global {
11+
namespace GraphileBuild {
12+
interface BehaviorStrings {
13+
filterBy: true;
14+
}
15+
}
16+
}
17+
1018
export const PgConnectionArgFilterComputedAttributesPlugin: GraphileConfig.Plugin =
1119
{
1220
name: "PgConnectionArgFilterComputedAttributesPlugin",
1321
version,
1422

1523
schema: {
24+
behaviorRegistry: {
25+
add: {
26+
filterBy: {
27+
description: "",
28+
entities: ["pgResource"],
29+
},
30+
},
31+
},
32+
1633
entityBehavior: {
1734
pgResource: {
1835
inferred(behavior, entity, build) {

src/PgConnectionArgFilterForwardRelationsPlugin.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,17 @@ export const PgConnectionArgFilterForwardRelationsPlugin: GraphileConfig.Plugin
2626
},
2727

2828
schema: {
29+
behaviorRegistry: {
30+
add: {
31+
filterBy: {
32+
description: "Can we filter by the results of this relation?",
33+
entities: ["pgCodecRelation"],
34+
},
35+
},
36+
},
37+
2938
entityBehavior: {
30-
pgCodecRelation: "filter",
39+
pgCodecRelation: "filterBy",
3140
},
3241

3342
hooks: {
@@ -73,7 +82,7 @@ export const PgConnectionArgFilterForwardRelationsPlugin: GraphileConfig.Plugin
7382
const foreignTable = relation.remoteResource; // Deliberate shadowing
7483

7584
// Used to use 'read' behavior too
76-
if (!build.behavior.pgCodecRelationMatches(relation, "filter")) {
85+
if (!build.behavior.pgCodecRelationMatches(relation, "filterBy")) {
7786
continue;
7887
}
7988

0 commit comments

Comments
 (0)