Skip to content

Commit 7319096

Browse files
author
mattia rossi
committed
Add EXPORTABLE decorator to function calls, to fix schema export capability
1 parent 479447a commit 7319096

7 files changed

Lines changed: 855 additions & 488 deletions

src/PgConnectionArgFilterAttributesPlugin.ts

Lines changed: 49 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const PgConnectionArgFilterAttributesPlugin: GraphileConfig.Plugin = {
1818
inflection,
1919
connectionFilterOperatorsDigest,
2020
dataplanPg: { PgConditionStep },
21+
EXPORTABLE,
2122
} = build;
2223
const {
2324
fieldWithHooks,
@@ -65,39 +66,56 @@ export const PgConnectionArgFilterAttributesPlugin: GraphileConfig.Plugin = {
6566
() => ({
6667
description: `Filter by the object’s \`${fieldName}\` field.`,
6768
type: OperatorsType,
68-
applyPlan($where: PgConditionStep<any>, fieldArgs) {
69-
const $raw = fieldArgs.getRaw();
70-
if ($raw.evalIs(undefined)) {
71-
return;
72-
}
73-
if (
74-
!connectionFilterAllowEmptyObjectInput &&
75-
"evalIsEmpty" in $raw &&
76-
$raw.evalIsEmpty()
77-
) {
78-
throw Object.assign(
79-
new Error(
80-
"Empty objects are forbidden in filter argument input."
81-
),
82-
{
83-
//TODO: mark this error as safe
69+
applyPlan: EXPORTABLE(
70+
(
71+
PgConditionStep,
72+
colSpec,
73+
connectionFilterAllowEmptyObjectInput,
74+
connectionFilterAllowNullInput
75+
) =>
76+
function ($where: PgConditionStep<any>, fieldArgs: any) {
77+
const $raw = fieldArgs.getRaw();
78+
if ($raw.evalIs(undefined)) {
79+
return;
8480
}
85-
);
86-
}
87-
if (!connectionFilterAllowNullInput && $raw.evalIs(null)) {
88-
throw Object.assign(
89-
new Error(
90-
"Null literals are forbidden in filter argument input."
91-
),
92-
{
93-
//TODO: mark this error as safe
81+
if (
82+
!connectionFilterAllowEmptyObjectInput &&
83+
"evalIsEmpty" in $raw &&
84+
$raw.evalIsEmpty()
85+
) {
86+
throw Object.assign(
87+
new Error(
88+
"Empty objects are forbidden in filter argument input."
89+
),
90+
{
91+
//TODO: mark this error as safe
92+
}
93+
);
9494
}
95-
);
96-
}
97-
const $col = new PgConditionStep($where);
98-
$col.extensions.pgFilterAttribute = colSpec;
99-
fieldArgs.apply($col);
100-
},
95+
if (
96+
!connectionFilterAllowNullInput &&
97+
$raw.evalIs(null)
98+
) {
99+
throw Object.assign(
100+
new Error(
101+
"Null literals are forbidden in filter argument input."
102+
),
103+
{
104+
//TODO: mark this error as safe
105+
}
106+
);
107+
}
108+
const $col = new PgConditionStep($where);
109+
$col.extensions.pgFilterAttribute = colSpec;
110+
fieldArgs.apply($col);
111+
},
112+
[
113+
PgConditionStep,
114+
colSpec,
115+
connectionFilterAllowEmptyObjectInput,
116+
connectionFilterAllowNullInput,
117+
]
118+
),
101119
})
102120
),
103121
},

0 commit comments

Comments
 (0)