Skip to content

Commit 8763d6c

Browse files
authored
chore(deps): upgrade dev deps, apply prettier formatting changes (#180)
1 parent 3a5d8d9 commit 8763d6c

11 files changed

+1477
-2686
lines changed

package.json

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@
2424
"tslib": "^2.3.0"
2525
},
2626
"devDependencies": {
27-
"@graphile-contrib/pg-simplify-inflector": "^6.1.0",
28-
"@types/jest": "26.0.22",
29-
"@typescript-eslint/eslint-plugin": "4.20.0",
30-
"@typescript-eslint/parser": "4.20.0",
31-
"eslint": "7.22.0",
32-
"eslint-config-prettier": "8.1.0",
33-
"eslint-plugin-jest": "24.3.3",
27+
"@graphile-contrib/pg-simplify-inflector": "6.1.0",
28+
"@types/jest": "27.4.1",
29+
"@typescript-eslint/eslint-plugin": "5.17.0",
30+
"@typescript-eslint/parser": "5.17.0",
31+
"eslint": "8.12.0",
32+
"eslint-config-prettier": "8.5.0",
33+
"eslint-plugin-jest": "26.1.3",
3434
"graphql": "14.7.0",
35-
"jest": "26.6.3",
36-
"pg": "8.5.1",
35+
"jest": "27.5.1",
36+
"pg": "8.7.3",
3737
"postgraphile-core": "4.5.0",
38-
"prettier": "2.2.1",
39-
"ts-jest": "26.5.4",
40-
"typescript": "4.2.3"
38+
"prettier": "2.6.2",
39+
"ts-jest": "27.1.4",
40+
"typescript": "4.6.3"
4141
},
4242
"files": [
4343
"dist"

src/PgConnectionArgFilterBackwardRelationsPlugin.ts

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
7171

7272
connectionFilterTypesByTypeName[Self.name] = Self;
7373

74-
const backwardRelationSpecs = (introspectionResultsByKind.constraint as PgConstraint[])
74+
const backwardRelationSpecs = (
75+
introspectionResultsByKind.constraint as PgConstraint[]
76+
)
7577
.filter((con) => con.type === "f")
7678
.filter((con) => con.foreignClassId === table.id)
7779
.reduce((memo: BackwardRelationSpec[], foreignConstraint) => {
@@ -91,10 +93,14 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
9193
if (omit(foreignTable, "read") || omit(foreignTable, "filter")) {
9294
return memo;
9395
}
94-
const attributes = (introspectionResultsByKind.attribute as PgAttribute[])
96+
const attributes = (
97+
introspectionResultsByKind.attribute as PgAttribute[]
98+
)
9599
.filter((attr) => attr.classId === table.id)
96100
.sort((a, b) => a.num - b.num);
97-
const foreignAttributes = (introspectionResultsByKind.attribute as PgAttribute[])
101+
const foreignAttributes = (
102+
introspectionResultsByKind.attribute as PgAttribute[]
103+
)
98104
.filter((attr) => attr.classId === foreignTable.id)
99105
.sort((a, b) => a.num - b.num);
100106
const keyAttributes = foreignConstraint.foreignKeyAttributeNums.map(
@@ -109,7 +115,9 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
109115
if (foreignKeyAttributes.some((attr) => omit(attr, "read"))) {
110116
return memo;
111117
}
112-
const isForeignKeyUnique = !!(introspectionResultsByKind.constraint as PgConstraint[]).find(
118+
const isForeignKeyUnique = !!(
119+
introspectionResultsByKind.constraint as PgConstraint[]
120+
).find(
113121
(c) =>
114122
c.classId === foreignTable.id &&
115123
(c.type === "p" || c.type === "u") &&
@@ -177,18 +185,14 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
177185
}) => {
178186
if (fieldValue == null) return null;
179187

180-
const {
181-
foreignTable,
182-
foreignKeyAttributes,
183-
keyAttributes,
184-
} = backwardRelationSpecByFieldName[fieldName];
188+
const { foreignTable, foreignKeyAttributes, keyAttributes } =
189+
backwardRelationSpecByFieldName[fieldName];
185190

186191
const foreignTableTypeName = inflection.tableType(foreignTable);
187192

188193
const foreignTableAlias = sql.identifier(Symbol());
189-
const foreignTableFilterTypeName = inflection.filterType(
190-
foreignTableTypeName
191-
);
194+
const foreignTableFilterTypeName =
195+
inflection.filterType(foreignTableTypeName);
192196
const sqlIdentifier = sql.identifier(
193197
foreignTable.namespace.name,
194198
foreignTable.name
@@ -220,11 +224,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
220224
}) => {
221225
if (fieldValue == null) return null;
222226

223-
const {
224-
foreignTable,
225-
foreignKeyAttributes,
226-
keyAttributes,
227-
} = backwardRelationSpecByFieldName[fieldName];
227+
const { foreignTable, foreignKeyAttributes, keyAttributes } =
228+
backwardRelationSpecByFieldName[fieldName];
228229

229230
const foreignTableAlias = sql.identifier(Symbol());
230231

@@ -287,9 +288,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
287288
isOneToMany,
288289
} = spec;
289290
const foreignTableTypeName = inflection.tableType(foreignTable);
290-
const foreignTableFilterTypeName = inflection.filterType(
291-
foreignTableTypeName
292-
);
291+
const foreignTableFilterTypeName =
292+
inflection.filterType(foreignTableTypeName);
293293
const ForeignTableFilterType = connectionFilterType(
294294
newWithHooks,
295295
foreignTableFilterTypeName,
@@ -332,9 +332,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
332332
table,
333333
foreignConstraint
334334
);
335-
const filterFieldName = inflection.filterManyRelationByKeysFieldName(
336-
fieldName
337-
);
335+
const filterFieldName =
336+
inflection.filterManyRelationByKeysFieldName(fieldName);
338337
addField(
339338
filterFieldName,
340339
`Filter by the object’s \`${fieldName}\` relation.`,
@@ -346,9 +345,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
346345
)} to ${describePgEntity(foreignTable)}`
347346
);
348347

349-
const existsFieldName = inflection.filterBackwardManyRelationExistsFieldName(
350-
fieldName
351-
);
348+
const existsFieldName =
349+
inflection.filterBackwardManyRelationExistsFieldName(fieldName);
352350
addField(
353351
existsFieldName,
354352
`Some related \`${fieldName}\` exist.`,
@@ -367,9 +365,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
367365
table,
368366
foreignConstraint
369367
);
370-
const filterFieldName = inflection.filterSingleRelationByKeysBackwardsFieldName(
371-
fieldName
372-
);
368+
const filterFieldName =
369+
inflection.filterSingleRelationByKeysBackwardsFieldName(fieldName);
373370
addField(
374371
filterFieldName,
375372
`Filter by the object’s \`${fieldName}\` relation.`,
@@ -381,9 +378,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
381378
)} to ${describePgEntity(foreignTable)}`
382379
);
383380

384-
const existsFieldName = inflection.filterBackwardSingleRelationExistsFieldName(
385-
fieldName
386-
);
381+
const existsFieldName =
382+
inflection.filterBackwardSingleRelationExistsFieldName(fieldName);
387383
addField(
388384
existsFieldName,
389385
`A related \`${fieldName}\` exists.`,
@@ -422,9 +418,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
422418
connectionFilterTypesByTypeName[Self.name] = Self;
423419

424420
const foreignTableTypeName = inflection.tableType(foreignTable);
425-
const foreignTableFilterTypeName = inflection.filterType(
426-
foreignTableTypeName
427-
);
421+
const foreignTableFilterTypeName =
422+
inflection.filterType(foreignTableTypeName);
428423
const FilterType = connectionFilterType(
429424
newWithHooks,
430425
foreignTableFilterTypeName,
@@ -476,10 +471,8 @@ const PgConnectionArgFilterBackwardRelationsPlugin: Plugin = (
476471

477472
if (!parentFieldInfo || !parentFieldInfo.backwardRelationSpec)
478473
throw new Error("Did not receive backward relation spec");
479-
const {
480-
keyAttributes,
481-
foreignKeyAttributes,
482-
}: BackwardRelationSpec = parentFieldInfo.backwardRelationSpec;
474+
const { keyAttributes, foreignKeyAttributes }: BackwardRelationSpec =
475+
parentFieldInfo.backwardRelationSpec;
483476

484477
const foreignTableAlias = sql.identifier(Symbol());
485478
const sqlIdentifier = sql.identifier(

src/PgConnectionArgFilterColumnsPlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ const PgConnectionArgFilterColumnsPlugin: Plugin = (builder) => {
2727

2828
connectionFilterTypesByTypeName[Self.name] = Self;
2929

30-
const attrByFieldName = (introspectionResultsByKind.attribute as PgAttribute[])
30+
const attrByFieldName = (
31+
introspectionResultsByKind.attribute as PgAttribute[]
32+
)
3133
.filter((attr) => attr.classId === table.id)
3234
.filter((attr) => pgColumnFilter(attr, build, context))
3335
.filter((attr) => !omit(attr, "filter"))

src/PgConnectionArgFilterCompositeTypeColumnsPlugin.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ const PgConnectionArgFilterCompositeTypeColumnsPlugin: Plugin = (
3131

3232
connectionFilterTypesByTypeName[Self.name] = Self;
3333

34-
const attrByFieldName = (introspectionResultsByKind.attribute as PgAttribute[])
34+
const attrByFieldName = (
35+
introspectionResultsByKind.attribute as PgAttribute[]
36+
)
3537
.filter((attr) => attr.classId === table.id)
3638
.filter((attr) => pgColumnFilter(attr, build, context))
3739
.filter((attr) => !omit(attr, "filter"))

src/PgConnectionArgFilterComputedColumnsPlugin.ts

Lines changed: 49 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -31,60 +31,58 @@ const PgConnectionArgFilterComputedColumnsPlugin: Plugin = (
3131

3232
connectionFilterTypesByTypeName[Self.name] = Self;
3333

34-
const procByFieldName = (introspectionResultsByKind.procedure as PgProc[]).reduce(
35-
(memo: { [fieldName: string]: PgProc }, proc) => {
36-
// Must be marked @filterable OR enabled via plugin option
37-
if (!(proc.tags.filterable || connectionFilterComputedColumns))
38-
return memo;
34+
const procByFieldName = (
35+
introspectionResultsByKind.procedure as PgProc[]
36+
).reduce((memo: { [fieldName: string]: PgProc }, proc) => {
37+
// Must be marked @filterable OR enabled via plugin option
38+
if (!(proc.tags.filterable || connectionFilterComputedColumns))
39+
return memo;
3940

40-
// Must not be omitted
41-
if (omit(proc, "execute")) return memo;
42-
if (omit(proc, "filter")) return memo;
41+
// Must not be omitted
42+
if (omit(proc, "execute")) return memo;
43+
if (omit(proc, "filter")) return memo;
4344

44-
// Must be a computed column
45-
const computedColumnDetails = getComputedColumnDetails(
46-
build,
47-
table,
48-
proc
49-
);
50-
if (!computedColumnDetails) return memo;
51-
const { pseudoColumnName } = computedColumnDetails;
52-
53-
// Must have only one required argument
54-
const inputArgsCount = proc.argTypeIds.filter(
55-
(_typeId, idx) =>
56-
proc.argModes.length === 0 || // all args are `in`
57-
proc.argModes[idx] === "i" || // this arg is `in`
58-
proc.argModes[idx] === "b" // this arg is `inout`
59-
).length;
60-
const nonOptionalArgumentsCount = inputArgsCount - proc.argDefaultsNum;
61-
if (nonOptionalArgumentsCount > 1) {
62-
return memo;
63-
}
64-
65-
// Must return a scalar or an array
66-
if (proc.returnsSet) return memo;
67-
const returnType =
68-
introspectionResultsByKind.typeById[proc.returnTypeId];
69-
const returnTypeTable =
70-
introspectionResultsByKind.classById[returnType.classId];
71-
if (returnTypeTable) return memo;
72-
const isRecordLike = returnType.id === "2249";
73-
if (isRecordLike) return memo;
74-
const isVoid = String(returnType.id) === "2278";
75-
if (isVoid) return memo;
76-
77-
// Looks good
78-
const fieldName = inflection.computedColumn(
79-
pseudoColumnName,
80-
proc,
81-
table
82-
);
83-
memo = build.extend(memo, { [fieldName]: proc });
45+
// Must be a computed column
46+
const computedColumnDetails = getComputedColumnDetails(
47+
build,
48+
table,
49+
proc
50+
);
51+
if (!computedColumnDetails) return memo;
52+
const { pseudoColumnName } = computedColumnDetails;
53+
54+
// Must have only one required argument
55+
const inputArgsCount = proc.argTypeIds.filter(
56+
(_typeId, idx) =>
57+
proc.argModes.length === 0 || // all args are `in`
58+
proc.argModes[idx] === "i" || // this arg is `in`
59+
proc.argModes[idx] === "b" // this arg is `inout`
60+
).length;
61+
const nonOptionalArgumentsCount = inputArgsCount - proc.argDefaultsNum;
62+
if (nonOptionalArgumentsCount > 1) {
8463
return memo;
85-
},
86-
{}
87-
);
64+
}
65+
66+
// Must return a scalar or an array
67+
if (proc.returnsSet) return memo;
68+
const returnType = introspectionResultsByKind.typeById[proc.returnTypeId];
69+
const returnTypeTable =
70+
introspectionResultsByKind.classById[returnType.classId];
71+
if (returnTypeTable) return memo;
72+
const isRecordLike = returnType.id === "2249";
73+
if (isRecordLike) return memo;
74+
const isVoid = String(returnType.id) === "2278";
75+
if (isVoid) return memo;
76+
77+
// Looks good
78+
const fieldName = inflection.computedColumn(
79+
pseudoColumnName,
80+
proc,
81+
table
82+
);
83+
memo = build.extend(memo, { [fieldName]: proc });
84+
return memo;
85+
}, {});
8886

8987
const operatorsTypeNameByFieldName: { [fieldName: string]: string } = {};
9088

0 commit comments

Comments
 (0)