graphile-build-pg 4.13.0 → 4.14.1
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/README.md +4 -13
- package/node8plus/GraphQLJSON.js +0 -11
- package/node8plus/GraphQLJSON.js.map +1 -1
- package/node8plus/PgLiveProvider.js +4 -11
- package/node8plus/PgLiveProvider.js.map +1 -1
- package/node8plus/QueryBuilder.js +42 -176
- package/node8plus/QueryBuilder.js.map +1 -1
- package/node8plus/index.js +8 -47
- package/node8plus/index.js.map +1 -1
- package/node8plus/inflections.js +9 -61
- package/node8plus/inflections.js.map +1 -1
- package/node8plus/omit.js +7 -22
- package/node8plus/omit.js.map +1 -1
- package/node8plus/parseIdentifier.js +0 -1
- package/node8plus/parseIdentifier.js.map +1 -1
- package/node8plus/pgPrepareAndRun.js +2 -14
- package/node8plus/pgPrepareAndRun.js.map +1 -1
- package/node8plus/plugins/PageInfoStartEndCursor.js +0 -4
- package/node8plus/plugins/PageInfoStartEndCursor.js.map +1 -1
- package/node8plus/plugins/PgAllRows.js +0 -29
- package/node8plus/plugins/PgAllRows.js.map +1 -1
- package/node8plus/plugins/PgBackwardRelationPlugin.js +2 -41
- package/node8plus/plugins/PgBackwardRelationPlugin.js.map +1 -1
- package/node8plus/plugins/PgBasicsPlugin.js +20 -147
- package/node8plus/plugins/PgBasicsPlugin.js.map +1 -1
- package/node8plus/plugins/PgColumnDeprecationPlugin.js +2 -5
- package/node8plus/plugins/PgColumnDeprecationPlugin.js.map +1 -1
- package/node8plus/plugins/PgColumnsPlugin.js +4 -17
- package/node8plus/plugins/PgColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgComputedColumnsPlugin.js +4 -19
- package/node8plus/plugins/PgComputedColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgConditionComputedColumnPlugin.js +12 -23
- package/node8plus/plugins/PgConditionComputedColumnPlugin.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgCondition.js +1 -9
- package/node8plus/plugins/PgConnectionArgCondition.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgFirstLastBeforeAfter.js +0 -12
- package/node8plus/plugins/PgConnectionArgFirstLastBeforeAfter.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgOrderBy.js +2 -19
- package/node8plus/plugins/PgConnectionArgOrderBy.js.map +1 -1
- package/node8plus/plugins/PgConnectionArgOrderByDefaultValue.js +0 -6
- package/node8plus/plugins/PgConnectionArgOrderByDefaultValue.js.map +1 -1
- package/node8plus/plugins/PgConnectionTotalCount.js +0 -8
- package/node8plus/plugins/PgConnectionTotalCount.js.map +1 -1
- package/node8plus/plugins/PgForwardRelationPlugin.js +2 -25
- package/node8plus/plugins/PgForwardRelationPlugin.js.map +1 -1
- package/node8plus/plugins/PgIntrospectionPlugin.js +91 -180
- package/node8plus/plugins/PgIntrospectionPlugin.js.flow +30 -2
- package/node8plus/plugins/PgIntrospectionPlugin.js.map +1 -1
- package/node8plus/plugins/PgJWTPlugin.js +2 -18
- package/node8plus/plugins/PgJWTPlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationCreatePlugin.js +0 -18
- package/node8plus/plugins/PgMutationCreatePlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationPayloadEdgePlugin.js +4 -25
- package/node8plus/plugins/PgMutationPayloadEdgePlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationProceduresPlugin.js +0 -6
- package/node8plus/plugins/PgMutationProceduresPlugin.js.map +1 -1
- package/node8plus/plugins/PgMutationUpdateDeletePlugin.js +14 -49
- package/node8plus/plugins/PgMutationUpdateDeletePlugin.js.flow +5 -2
- package/node8plus/plugins/PgMutationUpdateDeletePlugin.js.map +1 -1
- package/node8plus/plugins/PgNodeAliasPostGraphile.js +0 -6
- package/node8plus/plugins/PgNodeAliasPostGraphile.js.map +1 -1
- package/node8plus/plugins/PgOrderAllColumnsPlugin.js +0 -4
- package/node8plus/plugins/PgOrderAllColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgOrderByPrimaryKeyPlugin.js +0 -6
- package/node8plus/plugins/PgOrderByPrimaryKeyPlugin.js.map +1 -1
- package/node8plus/plugins/PgOrderComputedColumnsPlugin.js +10 -14
- package/node8plus/plugins/PgOrderComputedColumnsPlugin.js.map +1 -1
- package/node8plus/plugins/PgQueryProceduresPlugin.js +4 -16
- package/node8plus/plugins/PgQueryProceduresPlugin.js.map +1 -1
- package/node8plus/plugins/PgRecordFunctionConnectionPlugin.js +3 -20
- package/node8plus/plugins/PgRecordFunctionConnectionPlugin.js.map +1 -1
- package/node8plus/plugins/PgRecordReturnTypesPlugin.js +11 -16
- package/node8plus/plugins/PgRecordReturnTypesPlugin.js.map +1 -1
- package/node8plus/plugins/PgRowByUniqueConstraint.js +4 -25
- package/node8plus/plugins/PgRowByUniqueConstraint.js.map +1 -1
- package/node8plus/plugins/PgRowNode.js +0 -32
- package/node8plus/plugins/PgRowNode.js.map +1 -1
- package/node8plus/plugins/PgScalarFunctionConnectionPlugin.js +3 -17
- package/node8plus/plugins/PgScalarFunctionConnectionPlugin.js.map +1 -1
- package/node8plus/plugins/PgTablesPlugin.js +7 -59
- package/node8plus/plugins/PgTablesPlugin.js.map +1 -1
- package/node8plus/plugins/PgTypesPlugin.js +140 -240
- package/node8plus/plugins/PgTypesPlugin.js.flow +76 -23
- package/node8plus/plugins/PgTypesPlugin.js.map +1 -1
- package/node8plus/plugins/addStartEndCursor.js +2 -5
- package/node8plus/plugins/addStartEndCursor.js.map +1 -1
- package/node8plus/plugins/debugSql.js +1 -16
- package/node8plus/plugins/debugSql.js.map +1 -1
- package/node8plus/plugins/introspectionQuery.js +3 -4
- package/node8plus/plugins/introspectionQuery.js.flow +11 -3
- package/node8plus/plugins/introspectionQuery.js.map +1 -1
- package/node8plus/plugins/makeProcField.js +40 -90
- package/node8plus/plugins/makeProcField.js.map +1 -1
- package/node8plus/plugins/pgField.js +2 -7
- package/node8plus/plugins/pgField.js.map +1 -1
- package/node8plus/plugins/viaTemporaryTable.js +6 -12
- package/node8plus/plugins/viaTemporaryTable.js.map +1 -1
- package/node8plus/postgresInterval.js +4 -4
- package/node8plus/postgresInterval.js.map +1 -1
- package/node8plus/queryFromResolveDataFactory.js +33 -77
- package/node8plus/queryFromResolveDataFactory.js.map +1 -1
- package/node8plus/utils.js +8 -9
- package/node8plus/utils.js.map +1 -1
- package/node8plus/withPgClient.js +4 -26
- package/node8plus/withPgClient.js.map +1 -1
- package/package.json +4 -4
|
@@ -4,20 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _debug = _interopRequireDefault(require("debug"));
|
|
9
|
-
|
|
10
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
|
|
12
9
|
const debug = (0, _debug.default)("graphile-build-pg");
|
|
13
|
-
|
|
14
10
|
var PgMutationUpdateDeletePlugin = async function PgMutationUpdateDeletePlugin(builder, {
|
|
15
11
|
pgDisableDefaultMutations
|
|
16
12
|
}) {
|
|
17
13
|
if (pgDisableDefaultMutations) {
|
|
18
14
|
return;
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
builder.hook("GraphQLObjectType:fields", (fields, build, context) => {
|
|
22
17
|
const {
|
|
23
18
|
newWithHooks,
|
|
@@ -55,35 +50,30 @@ var PgMutationUpdateDeletePlugin = async function PgMutationUpdateDeletePlugin(b
|
|
|
55
50
|
},
|
|
56
51
|
fieldWithHooks
|
|
57
52
|
} = context;
|
|
58
|
-
|
|
59
53
|
if (!isRootMutation) {
|
|
60
54
|
return fields;
|
|
61
55
|
}
|
|
62
|
-
|
|
63
56
|
return extend(fields, ["update", "delete"].reduce((outerMemo, mode) => introspectionResultsByKind.class.reduce((memo, table) => {
|
|
64
57
|
// PERFORMANCE: These used to be .filter(...) calls
|
|
65
58
|
if (!table.namespace) return memo;
|
|
66
|
-
const canUpdate = mode === "update" && table.isUpdatable && !omit(table, "update") &&
|
|
59
|
+
const canUpdate = mode === "update" && table.isUpdatable && !omit(table, "update") &&
|
|
60
|
+
// Check at least one attribute is updatable
|
|
67
61
|
table.attributes.find(attr => !omit(attr, "update"));
|
|
68
62
|
const canDelete = mode === "delete" && table.isDeletable && !omit(table, "delete");
|
|
69
63
|
if (!canUpdate && !canDelete) return memo;
|
|
70
64
|
const TableType = pgGetGqlTypeByTypeIdAndModifier(table.type.id, null);
|
|
71
|
-
|
|
72
65
|
if (!TableType) {
|
|
73
66
|
return memo;
|
|
74
67
|
}
|
|
75
|
-
|
|
76
68
|
async function commonCodeRenameMe(pgClient, resolveInfo, getDataFromParsedResolveInfoFragment, PayloadType, args, condition, context, resolveContext) {
|
|
77
69
|
const {
|
|
78
70
|
input
|
|
79
71
|
} = args;
|
|
80
72
|
const parsedResolveInfoFragment = parseResolveInfo(resolveInfo);
|
|
81
73
|
parsedResolveInfoFragment.args = args; // Allow overriding via makeWrapResolversPlugin
|
|
82
|
-
|
|
83
74
|
const resolveData = getDataFromParsedResolveInfoFragment(parsedResolveInfoFragment, PayloadType);
|
|
84
75
|
const sqlTypeIdentifier = sql.identifier(table.namespace.name, table.name);
|
|
85
76
|
let sqlMutationQuery;
|
|
86
|
-
|
|
87
77
|
if (mode === "update") {
|
|
88
78
|
const sqlColumns = [];
|
|
89
79
|
const sqlValues = [];
|
|
@@ -93,20 +83,15 @@ var PgMutationUpdateDeletePlugin = async function PgMutationUpdateDeletePlugin(b
|
|
|
93
83
|
if (!pgColumnFilter(attr, build, context)) return;
|
|
94
84
|
if (omit(attr, "update")) return;
|
|
95
85
|
const fieldName = inflection.column(attr);
|
|
96
|
-
|
|
97
|
-
if (fieldName in inputData
|
|
98
|
-
/* Because we care about null! */
|
|
99
|
-
) {
|
|
86
|
+
if (fieldName in inputData /* Because we care about null! */) {
|
|
100
87
|
const val = inputData[fieldName];
|
|
101
88
|
sqlColumns.push(sql.identifier(attr.name));
|
|
102
89
|
sqlValues.push(gql2pg(val, attr.type, attr.typeModifier));
|
|
103
90
|
}
|
|
104
91
|
});
|
|
105
|
-
|
|
106
92
|
if (sqlColumns.length === 0) {
|
|
107
93
|
return null;
|
|
108
94
|
}
|
|
109
|
-
|
|
110
95
|
sqlMutationQuery = sql.query`\
|
|
111
96
|
update ${sql.identifier(table.namespace.name, table.name)} set ${sql.join(sqlColumns.map((col, i) => sql.fragment`${col} = ${sqlValues[i]}`), ", ")}
|
|
112
97
|
where ${condition}
|
|
@@ -117,11 +102,9 @@ delete from ${sql.identifier(table.namespace.name, table.name)}
|
|
|
117
102
|
where ${condition}
|
|
118
103
|
returning *`;
|
|
119
104
|
}
|
|
120
|
-
|
|
121
105
|
const modifiedRowAlias = sql.identifier(Symbol());
|
|
122
106
|
const query = queryFromResolveData(modifiedRowAlias, modifiedRowAlias, resolveData, {}, null, resolveContext, resolveInfo.rootValue);
|
|
123
107
|
let row;
|
|
124
|
-
|
|
125
108
|
try {
|
|
126
109
|
await pgClient.query("SAVEPOINT graphql_mutation");
|
|
127
110
|
const rows = await viaTemporaryTable(pgClient, sqlTypeIdentifier, sqlMutationQuery, modifiedRowAlias, query);
|
|
@@ -131,30 +114,30 @@ returning *`;
|
|
|
131
114
|
await pgClient.query("ROLLBACK TO SAVEPOINT graphql_mutation");
|
|
132
115
|
throw e;
|
|
133
116
|
}
|
|
134
|
-
|
|
135
117
|
if (!row) {
|
|
136
118
|
throw new Error(`No values were ${mode}d in collection '${inflection.pluralize(inflection._singularizedTableName(table))}' because no values you can ${mode} were found matching these criteria.`);
|
|
137
119
|
}
|
|
138
|
-
|
|
139
120
|
return {
|
|
140
121
|
clientMutationId: input.clientMutationId,
|
|
141
122
|
data: row
|
|
142
123
|
};
|
|
143
124
|
}
|
|
144
|
-
|
|
145
125
|
if (TableType) {
|
|
146
126
|
const uniqueConstraints = table.constraints.filter(con => con.type === "u" || con.type === "p");
|
|
147
127
|
const Table = pgGetGqlTypeByTypeIdAndModifier(table.type.id, null);
|
|
148
128
|
const tableTypeName = Table.name;
|
|
149
129
|
const TablePatch = getTypeByName(inflection.patchType(Table.name));
|
|
130
|
+
if (mode === "update" && !TablePatch) {
|
|
131
|
+
return memo;
|
|
132
|
+
}
|
|
150
133
|
const PayloadType = newWithHooks(GraphQLObjectType, {
|
|
151
134
|
name: inflection[mode === "delete" ? "deletePayloadType" : "updatePayloadType"](table),
|
|
152
135
|
description: build.wrapDescription(`The output of our ${mode} \`${tableTypeName}\` mutation.`, "type"),
|
|
153
136
|
fields: ({
|
|
154
137
|
fieldWithHooks
|
|
155
138
|
}) => {
|
|
156
|
-
const tableName = inflection.tableFieldName(table);
|
|
157
|
-
|
|
139
|
+
const tableName = inflection.tableFieldName(table);
|
|
140
|
+
// This should really be `-node-id` but for compatibility with PostGraphQL v3 we haven't made that change.
|
|
158
141
|
const deletedNodeIdFieldName = inflection.deletedNodeId(table);
|
|
159
142
|
return Object.assign({
|
|
160
143
|
clientMutationId: {
|
|
@@ -171,18 +154,14 @@ returning *`;
|
|
|
171
154
|
}) => {
|
|
172
155
|
const fieldDataGeneratorsByTableType = fieldDataGeneratorsByType.get(TableType);
|
|
173
156
|
const gens = fieldDataGeneratorsByTableType && fieldDataGeneratorsByTableType[nodeIdFieldName];
|
|
174
|
-
|
|
175
157
|
if (gens) {
|
|
176
158
|
gens.forEach(gen => addDataGenerator(gen));
|
|
177
159
|
}
|
|
178
|
-
|
|
179
160
|
return {
|
|
180
161
|
type: GraphQLID,
|
|
181
|
-
|
|
182
162
|
resolve(data) {
|
|
183
163
|
return data.data.__identifiers && getNodeIdForTypeAndIdentifiers(Table, ...data.data.__identifiers);
|
|
184
164
|
}
|
|
185
|
-
|
|
186
165
|
};
|
|
187
166
|
}, {
|
|
188
167
|
isPgMutationPayloadDeletedNodeIdField: true
|
|
@@ -197,10 +176,10 @@ returning *`;
|
|
|
197
176
|
isPgUpdatePayloadType: mode === "update",
|
|
198
177
|
isPgDeletePayloadType: mode === "delete",
|
|
199
178
|
pgIntrospection: table
|
|
200
|
-
});
|
|
179
|
+
});
|
|
201
180
|
|
|
181
|
+
// NodeId
|
|
202
182
|
const primaryKeyConstraint = table.primaryKeyConstraint;
|
|
203
|
-
|
|
204
183
|
if (nodeIdFieldName && primaryKeyConstraint) {
|
|
205
184
|
const primaryKeys = primaryKeyConstraint && primaryKeyConstraint.keyAttributes;
|
|
206
185
|
const fieldName = inflection[mode === "update" ? "updateNode" : "deleteNode"](table);
|
|
@@ -216,7 +195,7 @@ returning *`;
|
|
|
216
195
|
description: build.wrapDescription(`The globally unique \`ID\` which will identify a single \`${tableTypeName}\` to be ${mode}d.`, "field"),
|
|
217
196
|
type: new GraphQLNonNull(GraphQLID)
|
|
218
197
|
}
|
|
219
|
-
}, mode === "update" ? {
|
|
198
|
+
}, mode === "update" && TablePatch ? {
|
|
220
199
|
[inflection.patchField(inflection.tableFieldName(table))]: {
|
|
221
200
|
description: build.wrapDescription(`An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`, "field"),
|
|
222
201
|
type: new GraphQLNonNull(TablePatch)
|
|
@@ -248,7 +227,6 @@ returning *`;
|
|
|
248
227
|
type: new GraphQLNonNull(InputType)
|
|
249
228
|
}
|
|
250
229
|
},
|
|
251
|
-
|
|
252
230
|
async resolve(parent, args, resolveContext, resolveInfo) {
|
|
253
231
|
const {
|
|
254
232
|
input
|
|
@@ -257,28 +235,23 @@ returning *`;
|
|
|
257
235
|
pgClient
|
|
258
236
|
} = resolveContext;
|
|
259
237
|
const nodeId = input[nodeIdFieldName];
|
|
260
|
-
|
|
261
238
|
try {
|
|
262
239
|
const {
|
|
263
240
|
Type,
|
|
264
241
|
identifiers
|
|
265
242
|
} = getTypeAndIdentifiersFromNodeId(nodeId);
|
|
266
|
-
|
|
267
243
|
if (Type !== TableType) {
|
|
268
244
|
throw new Error("Mismatched type");
|
|
269
245
|
}
|
|
270
|
-
|
|
271
246
|
if (identifiers.length !== primaryKeys.length) {
|
|
272
247
|
throw new Error("Invalid ID");
|
|
273
248
|
}
|
|
274
|
-
|
|
275
249
|
return commonCodeRenameMe(pgClient, resolveInfo, getDataFromParsedResolveInfoFragment, PayloadType, args, sql.fragment`(${sql.join(primaryKeys.map((key, idx) => sql.fragment`${sql.identifier(key.name)} = ${gql2pg(identifiers[idx], key.type, key.typeModifier)}`), ") and (")})`, context, resolveContext);
|
|
276
250
|
} catch (e) {
|
|
277
251
|
debug(e);
|
|
278
252
|
return null;
|
|
279
253
|
}
|
|
280
254
|
}
|
|
281
|
-
|
|
282
255
|
};
|
|
283
256
|
}, {
|
|
284
257
|
isPgNodeMutation: true,
|
|
@@ -286,24 +259,20 @@ returning *`;
|
|
|
286
259
|
[mode === "update" ? "isPgUpdateMutationField" : "isPgDeleteMutationField"]: true
|
|
287
260
|
})
|
|
288
261
|
}, "Adding ${mode} mutation for ${describePgEntity(table)}");
|
|
289
|
-
}
|
|
290
|
-
|
|
262
|
+
}
|
|
291
263
|
|
|
264
|
+
// Unique
|
|
292
265
|
uniqueConstraints.forEach(constraint => {
|
|
293
266
|
if (omit(constraint, mode)) {
|
|
294
267
|
return;
|
|
295
268
|
}
|
|
296
|
-
|
|
297
269
|
const keys = constraint.keyAttributes;
|
|
298
|
-
|
|
299
270
|
if (!keys.every(_ => _)) {
|
|
300
271
|
throw new Error(`Consistency error: could not find an attribute in the constraint when building the ${mode} mutation for ${describePgEntity(table)}!`);
|
|
301
272
|
}
|
|
302
|
-
|
|
303
273
|
if (keys.some(key => omit(key, "read"))) {
|
|
304
274
|
return;
|
|
305
275
|
}
|
|
306
|
-
|
|
307
276
|
const fieldName = inflection[mode === "update" ? "updateByKeys" : "deleteByKeys"](keys, table, constraint);
|
|
308
277
|
const InputType = newWithHooks(GraphQLInputObjectType, {
|
|
309
278
|
description: build.wrapDescription(`All input for the \`${fieldName}\` mutation.`, "type"),
|
|
@@ -312,7 +281,7 @@ returning *`;
|
|
|
312
281
|
clientMutationId: {
|
|
313
282
|
type: GraphQLString
|
|
314
283
|
}
|
|
315
|
-
}, mode === "update" ? {
|
|
284
|
+
}, mode === "update" && TablePatch ? {
|
|
316
285
|
[inflection.patchField(inflection.tableFieldName(table))]: {
|
|
317
286
|
description: build.wrapDescription(`An object where the defined keys will be set on the \`${tableTypeName}\` being ${mode}d.`, "field"),
|
|
318
287
|
type: new GraphQLNonNull(TablePatch)
|
|
@@ -351,7 +320,6 @@ returning *`;
|
|
|
351
320
|
type: new GraphQLNonNull(InputType)
|
|
352
321
|
}
|
|
353
322
|
},
|
|
354
|
-
|
|
355
323
|
async resolve(parent, args, resolveContext, resolveInfo) {
|
|
356
324
|
const {
|
|
357
325
|
input
|
|
@@ -361,7 +329,6 @@ returning *`;
|
|
|
361
329
|
} = resolveContext;
|
|
362
330
|
return commonCodeRenameMe(pgClient, resolveInfo, getDataFromParsedResolveInfoFragment, PayloadType, args, sql.fragment`(${sql.join(keys.map(key => sql.fragment`${sql.identifier(key.name)} = ${gql2pg(input[inflection.column(key)], key.type, key.typeModifier)}`), ") and (")})`, context, resolveContext);
|
|
363
331
|
}
|
|
364
|
-
|
|
365
332
|
};
|
|
366
333
|
}, {
|
|
367
334
|
isPgNodeMutation: false,
|
|
@@ -372,11 +339,9 @@ returning *`;
|
|
|
372
339
|
}, `Adding ${mode} mutation for ${describePgEntity(constraint)}`);
|
|
373
340
|
});
|
|
374
341
|
}
|
|
375
|
-
|
|
376
342
|
return memo;
|
|
377
343
|
}, outerMemo), {}), `Adding default update/delete mutations to root Mutation type`);
|
|
378
344
|
}, ["PgMutationUpdateDelete"]);
|
|
379
345
|
};
|
|
380
|
-
|
|
381
346
|
exports.default = PgMutationUpdateDeletePlugin;
|
|
382
347
|
//# sourceMappingURL=PgMutationUpdateDeletePlugin.js.map
|
|
@@ -196,6 +196,9 @@ returning *`;
|
|
|
196
196
|
const TablePatch = getTypeByName(
|
|
197
197
|
inflection.patchType(Table.name)
|
|
198
198
|
);
|
|
199
|
+
if (mode === "update" && !TablePatch) {
|
|
200
|
+
return memo;
|
|
201
|
+
}
|
|
199
202
|
const PayloadType = newWithHooks(
|
|
200
203
|
GraphQLObjectType,
|
|
201
204
|
{
|
|
@@ -329,7 +332,7 @@ returning *`;
|
|
|
329
332
|
type: new GraphQLNonNull(GraphQLID),
|
|
330
333
|
},
|
|
331
334
|
},
|
|
332
|
-
mode === "update"
|
|
335
|
+
mode === "update" && TablePatch
|
|
333
336
|
? {
|
|
334
337
|
[inflection.patchField(
|
|
335
338
|
inflection.tableFieldName(table)
|
|
@@ -482,7 +485,7 @@ returning *`;
|
|
|
482
485
|
type: GraphQLString,
|
|
483
486
|
},
|
|
484
487
|
},
|
|
485
|
-
mode === "update"
|
|
488
|
+
mode === "update" && TablePatch
|
|
486
489
|
? {
|
|
487
490
|
[inflection.patchField(
|
|
488
491
|
inflection.tableFieldName(table)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/plugins/PgMutationUpdateDeletePlugin.js"],"names":["debug","PgMutationUpdateDeletePlugin","builder","pgDisableDefaultMutations","hook","fields","build","context","newWithHooks","getNodeIdForTypeAndIdentifiers","getTypeAndIdentifiersFromNodeId","nodeIdFieldName","fieldDataGeneratorsByType","extend","parseResolveInfo","getTypeByName","gql2pg","pgGetGqlTypeByTypeIdAndModifier","pgGetGqlInputTypeByTypeIdAndModifier","pgIntrospectionResultsByKind","introspectionResultsByKind","pgSql","sql","graphql","GraphQLNonNull","GraphQLInputObjectType","GraphQLString","GraphQLObjectType","GraphQLID","pgColumnFilter","inflection","pgQueryFromResolveData","queryFromResolveData","pgOmit","omit","pgViaTemporaryTable","viaTemporaryTable","describePgEntity","sqlCommentByAddingTags","pgField","scope","isRootMutation","fieldWithHooks","reduce","outerMemo","mode","class","memo","table","namespace","canUpdate","isUpdatable","attributes","find","attr","canDelete","isDeletable","TableType","type","id","commonCodeRenameMe","pgClient","resolveInfo","getDataFromParsedResolveInfoFragment","PayloadType","args","condition","resolveContext","input","parsedResolveInfoFragment","resolveData","sqlTypeIdentifier","identifier","name","sqlMutationQuery","sqlColumns","sqlValues","inputData","patchField","tableFieldName","forEach","fieldName","column","val","push","typeModifier","length","query","join","map","col","i","fragment","modifiedRowAlias","Symbol","rootValue","row","rows","e","Error","pluralize","_singularizedTableName","clientMutationId","data","uniqueConstraints","constraints","filter","con","Table","tableTypeName","TablePatch","patchType","description","wrapDescription","tableName","deletedNodeIdFieldName","deletedNodeId","Object","assign","addDataGenerator","fieldDataGeneratorsByTableType","get","gens","gen","resolve","__identifiers","isPgMutationPayloadDeletedNodeIdField","__origin","isMutationPayload","isPgUpdatePayloadType","isPgDeletePayloadType","pgIntrospection","primaryKeyConstraint","primaryKeys","keyAttributes","InputType","isPgUpdateInputType","isPgUpdateNodeInputType","isPgDeleteInputType","isPgDeleteNodeInputType","pgInflection","isMutationInput","parent","nodeId","Type","identifiers","key","idx","isPgNodeMutation","pgFieldIntrospection","constraint","keys","every","_","some","typeId","isPgUpdateByKeysInputType","isPgDeleteByKeysInputType","pgKeys","pgFieldConstraint"],"mappings":";;;;;;;AAEA;;;;AAEA,MAAMA,KAAK,GAAG,oBAAa,mBAAb,CAAd;;IAE+BC,4B,GAAf,eAAeA,4BAAf,CACdC,OADc,EAEd;AAAEC,EAAAA;AAAF,CAFc,EAGd;AACA,MAAIA,yBAAJ,EAA+B;AAC7B;AACD;;AAEDD,EAAAA,OAAO,CAACE,IAAR,CACE,0BADF,EAEE,CAACC,MAAD,EAASC,KAAT,EAAgBC,OAAhB,KAA4B;AAC1B,UAAM;AACJC,MAAAA,YADI;AAEJC,MAAAA,8BAFI;AAGJC,MAAAA,+BAHI;AAIJC,MAAAA,eAJI;AAKJC,MAAAA,yBALI;AAMJC,MAAAA,MANI;AAOJC,MAAAA,gBAPI;AAQJC,MAAAA,aARI;AASJC,MAAAA,MATI;AAUJC,MAAAA,+BAVI;AAWJC,MAAAA,oCAXI;AAYJC,MAAAA,4BAA4B,EAAEC,0BAZ1B;AAaJC,MAAAA,KAAK,EAAEC,GAbH;AAcJC,MAAAA,OAAO,EAAE;AACP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F,EAEE7E,IAFF,EAGEE,cAHF,EAIEL,WAJF,EAKE;AACA,wBAAM;AAAEM,oBAAAA;AAAF,sBAAYH,IAAlB;AACA,wBAAM;AAAEJ,oBAAAA;AAAF,sBAAeM,cAArB;AACA,yBAAOP,kBAAkB,CACvBC,QADuB,EAEvBC,WAFuB,EAGvBC,oCAHuB,EAIvBC,WAJuB,EAKvBC,IALuB,EAMvB3C,GAAG,CAACsE,QAAS,IAAGtE,GAAG,CAACkE,IAAJ,CACd+D,IAAI,CAAC9D,GAAL,CACEyD,GAAG,IACD5H,GAAG,CAACsE,QAAS,GAAEtE,GAAG,CAACkD,UAAJ,CACb0E,GAAG,CAACzE,IADS,CAEb,MAAKzD,MAAM,CACXoD,KAAK,CAACtC,UAAU,CAACoD,MAAX,CAAkBgE,GAAlB,CAAD,CADM,EAEXA,GAAG,CAACxF,IAFO,EAGXwF,GAAG,CAAC7D,YAHO,CAIX,EARN,CADc,EAWd,SAXc,CAYd,GAlBqB,EAmBvB9E,OAnBuB,EAoBvB4D,cApBuB,CAAzB;AAsBD;;AA3CI,eAAP;AA6CD,aAlDwB,EAmDzB;AACEiF,cAAAA,gBAAgB,EAAE,KADpB;AAEEC,cAAAA,oBAAoB,EAAErG,KAFxB;AAGE+G,cAAAA,iBAAiB,EAAET,UAHrB;AAIE,eAACzG,IAAI,KAAK,QAAT,GACG,yBADH,GAEG,yBAFJ,GAEgC;AANlC,aAnDyB;AAD7B,WAFW,EAgEV,UAASA,IAAK,iBAAgBR,gBAAgB,CAC7CiH,UAD6C,CAE7C,EAlES,CAAb;AAoED,SAvJD;AAwJD;;AACD,aAAOvG,IAAP;AACD,KA9hBD,EA8hBGH,SA9hBH,CAFJ,EAiiBE,EAjiBF,CAFW,EAqiBV,8DAriBU,CAAb;AAuiBD,GAjlBH,EAklBE,CAAC,wBAAD,CAllBF;AAolBD,C","sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\nimport debugFactory from \"debug\";\n\nconst debug = debugFactory(\"graphile-build-pg\");\n\nexport default (async function PgMutationUpdateDeletePlugin(\n builder,\n { pgDisableDefaultMutations }\n) {\n if (pgDisableDefaultMutations) {\n return;\n }\n\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n newWithHooks,\n getNodeIdForTypeAndIdentifiers,\n getTypeAndIdentifiersFromNodeId,\n nodeIdFieldName,\n fieldDataGeneratorsByType,\n extend,\n parseResolveInfo,\n getTypeByName,\n gql2pg,\n pgGetGqlTypeByTypeIdAndModifier,\n pgGetGqlInputTypeByTypeIdAndModifier,\n pgIntrospectionResultsByKind: introspectionResultsByKind,\n pgSql: sql,\n graphql: {\n GraphQLNonNull,\n GraphQLInputObjectType,\n GraphQLString,\n GraphQLObjectType,\n GraphQLID,\n },\n pgColumnFilter,\n inflection,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n pgViaTemporaryTable: viaTemporaryTable,\n describePgEntity,\n sqlCommentByAddingTags,\n pgField,\n } = build;\n const {\n scope: { isRootMutation },\n fieldWithHooks,\n } = context;\n\n if (!isRootMutation) {\n return fields;\n }\n\n return extend(\n fields,\n [\"update\", \"delete\"].reduce(\n (outerMemo, mode) =>\n introspectionResultsByKind.class.reduce((memo, table) => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!table.namespace) return memo;\n const canUpdate =\n mode === \"update\" &&\n table.isUpdatable &&\n !omit(table, \"update\") &&\n // Check at least one attribute is updatable\n table.attributes.find(attr => !omit(attr, \"update\"));\n const canDelete =\n mode === \"delete\" &&\n table.isDeletable &&\n !omit(table, \"delete\");\n if (!canUpdate && !canDelete) return memo;\n\n const TableType = pgGetGqlTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n if (!TableType) {\n return memo;\n }\n async function commonCodeRenameMe(\n pgClient,\n resolveInfo,\n getDataFromParsedResolveInfoFragment,\n PayloadType,\n args,\n condition,\n context,\n resolveContext\n ) {\n const { input } = args;\n const parsedResolveInfoFragment = parseResolveInfo(resolveInfo);\n parsedResolveInfoFragment.args = args; // Allow overriding via makeWrapResolversPlugin\n const resolveData = getDataFromParsedResolveInfoFragment(\n parsedResolveInfoFragment,\n PayloadType\n );\n\n const sqlTypeIdentifier = sql.identifier(\n table.namespace.name,\n table.name\n );\n\n let sqlMutationQuery;\n if (mode === \"update\") {\n const sqlColumns = [];\n const sqlValues = [];\n const inputData =\n input[\n inflection.patchField(inflection.tableFieldName(table))\n ];\n table.attributes.forEach(attr => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!pgColumnFilter(attr, build, context)) return;\n if (omit(attr, \"update\")) return;\n\n const fieldName = inflection.column(attr);\n if (\n fieldName in inputData /* Because we care about null! */\n ) {\n const val = inputData[fieldName];\n sqlColumns.push(sql.identifier(attr.name));\n sqlValues.push(gql2pg(val, attr.type, attr.typeModifier));\n }\n });\n if (sqlColumns.length === 0) {\n return null;\n }\n sqlMutationQuery = sql.query`\\\nupdate ${sql.identifier(table.namespace.name, table.name)} set ${sql.join(\n sqlColumns.map(\n (col, i) => sql.fragment`${col} = ${sqlValues[i]}`\n ),\n \", \"\n )}\nwhere ${condition}\nreturning *`;\n } else {\n sqlMutationQuery = sql.query`\\\ndelete from ${sql.identifier(table.namespace.name, table.name)}\nwhere ${condition}\nreturning *`;\n }\n\n const modifiedRowAlias = sql.identifier(Symbol());\n const query = queryFromResolveData(\n modifiedRowAlias,\n modifiedRowAlias,\n resolveData,\n {},\n null,\n resolveContext,\n resolveInfo.rootValue\n );\n let row;\n try {\n await pgClient.query(\"SAVEPOINT graphql_mutation\");\n const rows = await viaTemporaryTable(\n pgClient,\n sqlTypeIdentifier,\n sqlMutationQuery,\n modifiedRowAlias,\n query\n );\n row = rows[0];\n await pgClient.query(\"RELEASE SAVEPOINT graphql_mutation\");\n } catch (e) {\n await pgClient.query(\n \"ROLLBACK TO SAVEPOINT graphql_mutation\"\n );\n throw e;\n }\n if (!row) {\n throw new Error(\n `No values were ${mode}d in collection '${inflection.pluralize(\n inflection._singularizedTableName(table)\n )}' because no values you can ${mode} were found matching these criteria.`\n );\n }\n return {\n clientMutationId: input.clientMutationId,\n data: row,\n };\n }\n if (TableType) {\n const uniqueConstraints = table.constraints.filter(\n con => con.type === \"u\" || con.type === \"p\"\n );\n const Table = pgGetGqlTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n const tableTypeName = Table.name;\n const TablePatch = getTypeByName(\n inflection.patchType(Table.name)\n );\n const PayloadType = newWithHooks(\n GraphQLObjectType,\n {\n name: inflection[\n mode === \"delete\"\n ? \"deletePayloadType\"\n : \"updatePayloadType\"\n ](table),\n description: build.wrapDescription(\n `The output of our ${mode} \\`${tableTypeName}\\` mutation.`,\n \"type\"\n ),\n fields: ({ fieldWithHooks }) => {\n const tableName = inflection.tableFieldName(table);\n // This should really be `-node-id` but for compatibility with PostGraphQL v3 we haven't made that change.\n const deletedNodeIdFieldName =\n inflection.deletedNodeId(table);\n return Object.assign(\n {\n clientMutationId: {\n description: build.wrapDescription(\n \"The exact same `clientMutationId` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations.\",\n \"field\"\n ),\n type: GraphQLString,\n },\n [tableName]: pgField(\n build,\n fieldWithHooks,\n tableName,\n {\n description: build.wrapDescription(\n `The \\`${tableTypeName}\\` that was ${mode}d by this mutation.`,\n \"field\"\n ),\n type: Table,\n },\n {},\n false\n ),\n },\n mode === \"delete\"\n ? {\n [deletedNodeIdFieldName]: fieldWithHooks(\n deletedNodeIdFieldName,\n ({ addDataGenerator }) => {\n const fieldDataGeneratorsByTableType =\n fieldDataGeneratorsByType.get(TableType);\n\n const gens =\n fieldDataGeneratorsByTableType &&\n fieldDataGeneratorsByTableType[\n nodeIdFieldName\n ];\n if (gens) {\n gens.forEach(gen => addDataGenerator(gen));\n }\n return {\n type: GraphQLID,\n resolve(data) {\n return (\n data.data.__identifiers &&\n getNodeIdForTypeAndIdentifiers(\n Table,\n ...data.data.__identifiers\n )\n );\n },\n };\n },\n {\n isPgMutationPayloadDeletedNodeIdField: true,\n }\n ),\n }\n : null\n );\n },\n },\n {\n __origin: `Adding table ${mode} mutation payload type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isMutationPayload: true,\n isPgUpdatePayloadType: mode === \"update\",\n isPgDeletePayloadType: mode === \"delete\",\n pgIntrospection: table,\n }\n );\n\n // NodeId\n const primaryKeyConstraint = table.primaryKeyConstraint;\n if (nodeIdFieldName && primaryKeyConstraint) {\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n const fieldName =\n inflection[mode === \"update\" ? \"updateNode\" : \"deleteNode\"](\n table\n );\n const InputType = newWithHooks(\n GraphQLInputObjectType,\n {\n description: build.wrapDescription(\n `All input for the \\`${fieldName}\\` mutation.`,\n \"type\"\n ),\n name: inflection[\n mode === \"update\"\n ? \"updateNodeInputType\"\n : \"deleteNodeInputType\"\n ](table),\n fields: Object.assign(\n {\n clientMutationId: {\n description: build.wrapDescription(\n \"An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client.\",\n \"field\"\n ),\n type: GraphQLString,\n },\n [nodeIdFieldName]: {\n description: build.wrapDescription(\n `The globally unique \\`ID\\` which will identify a single \\`${tableTypeName}\\` to be ${mode}d.`,\n \"field\"\n ),\n type: new GraphQLNonNull(GraphQLID),\n },\n },\n mode === \"update\"\n ? {\n [inflection.patchField(\n inflection.tableFieldName(table)\n )]: {\n description: build.wrapDescription(\n `An object where the defined keys will be set on the \\`${tableTypeName}\\` being ${mode}d.`,\n \"field\"\n ),\n type: new GraphQLNonNull(TablePatch),\n },\n }\n : null\n ),\n },\n {\n __origin: `Adding table ${mode} (by node ID) mutation input type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isPgUpdateInputType: mode === \"update\",\n isPgUpdateNodeInputType: mode === \"update\",\n isPgDeleteInputType: mode === \"delete\",\n isPgDeleteNodeInputType: mode === \"delete\",\n pgInflection: table, // TODO:v5: remove - TYPO!\n pgIntrospection: table,\n isMutationInput: true,\n }\n );\n\n memo = extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n context => {\n const { getDataFromParsedResolveInfoFragment } =\n context;\n return {\n description: build.wrapDescription(\n mode === \"update\"\n ? `Updates a single \\`${tableTypeName}\\` using its globally unique id and a patch.`\n : `Deletes a single \\`${tableTypeName}\\` using its globally unique id.`,\n \"field\"\n ),\n type: PayloadType,\n args: {\n input: {\n type: new GraphQLNonNull(InputType),\n },\n },\n async resolve(\n parent,\n args,\n resolveContext,\n resolveInfo\n ) {\n const { input } = args;\n const { pgClient } = resolveContext;\n const nodeId = input[nodeIdFieldName];\n try {\n const { Type, identifiers } =\n getTypeAndIdentifiersFromNodeId(nodeId);\n if (Type !== TableType) {\n throw new Error(\"Mismatched type\");\n }\n if (identifiers.length !== primaryKeys.length) {\n throw new Error(\"Invalid ID\");\n }\n\n return commonCodeRenameMe(\n pgClient,\n resolveInfo,\n getDataFromParsedResolveInfoFragment,\n PayloadType,\n args,\n sql.fragment`(${sql.join(\n primaryKeys.map(\n (key, idx) =>\n sql.fragment`${sql.identifier(\n key.name\n )} = ${gql2pg(\n identifiers[idx],\n key.type,\n key.typeModifier\n )}`\n ),\n \") and (\"\n )})`,\n context,\n resolveContext\n );\n } catch (e) {\n debug(e);\n return null;\n }\n },\n };\n },\n {\n isPgNodeMutation: true,\n pgFieldIntrospection: table,\n [mode === \"update\"\n ? \"isPgUpdateMutationField\"\n : \"isPgDeleteMutationField\"]: true,\n }\n ),\n },\n \"Adding ${mode} mutation for ${describePgEntity(table)}\"\n );\n }\n\n // Unique\n uniqueConstraints.forEach(constraint => {\n if (omit(constraint, mode)) {\n return;\n }\n const keys = constraint.keyAttributes;\n if (!keys.every(_ => _)) {\n throw new Error(\n `Consistency error: could not find an attribute in the constraint when building the ${mode} mutation for ${describePgEntity(\n table\n )}!`\n );\n }\n if (keys.some(key => omit(key, \"read\"))) {\n return;\n }\n const fieldName = inflection[\n mode === \"update\" ? \"updateByKeys\" : \"deleteByKeys\"\n ](keys, table, constraint);\n const InputType = newWithHooks(\n GraphQLInputObjectType,\n {\n description: build.wrapDescription(\n `All input for the \\`${fieldName}\\` mutation.`,\n \"type\"\n ),\n name: inflection[\n mode === \"update\"\n ? \"updateByKeysInputType\"\n : \"deleteByKeysInputType\"\n ](keys, table, constraint),\n fields: Object.assign(\n {\n clientMutationId: {\n type: GraphQLString,\n },\n },\n mode === \"update\"\n ? {\n [inflection.patchField(\n inflection.tableFieldName(table)\n )]: {\n description: build.wrapDescription(\n `An object where the defined keys will be set on the \\`${tableTypeName}\\` being ${mode}d.`,\n \"field\"\n ),\n type: new GraphQLNonNull(TablePatch),\n },\n }\n : null,\n keys.reduce((memo, key) => {\n memo[inflection.column(key)] = {\n description: key.description,\n type: new GraphQLNonNull(\n pgGetGqlInputTypeByTypeIdAndModifier(\n key.typeId,\n key.typeModifier\n )\n ),\n };\n return memo;\n }, {})\n ),\n },\n {\n __origin: `Adding table ${mode} mutation input type for ${describePgEntity(\n constraint\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isPgUpdateInputType: mode === \"update\",\n isPgUpdateByKeysInputType: mode === \"update\",\n isPgDeleteInputType: mode === \"delete\",\n isPgDeleteByKeysInputType: mode === \"delete\",\n pgInflection: table, // TODO:v5: remove - TYPO!\n pgIntrospection: table,\n pgKeys: keys,\n isMutationInput: true,\n }\n );\n\n memo = extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n context => {\n const { getDataFromParsedResolveInfoFragment } =\n context;\n return {\n description: build.wrapDescription(\n mode === \"update\"\n ? `Updates a single \\`${tableTypeName}\\` using a unique key and a patch.`\n : `Deletes a single \\`${tableTypeName}\\` using a unique key.`,\n \"field\"\n ),\n type: PayloadType,\n args: {\n input: {\n type: new GraphQLNonNull(InputType),\n },\n },\n async resolve(\n parent,\n args,\n resolveContext,\n resolveInfo\n ) {\n const { input } = args;\n const { pgClient } = resolveContext;\n return commonCodeRenameMe(\n pgClient,\n resolveInfo,\n getDataFromParsedResolveInfoFragment,\n PayloadType,\n args,\n sql.fragment`(${sql.join(\n keys.map(\n key =>\n sql.fragment`${sql.identifier(\n key.name\n )} = ${gql2pg(\n input[inflection.column(key)],\n key.type,\n key.typeModifier\n )}`\n ),\n \") and (\"\n )})`,\n context,\n resolveContext\n );\n },\n };\n },\n {\n isPgNodeMutation: false,\n pgFieldIntrospection: table,\n pgFieldConstraint: constraint,\n [mode === \"update\"\n ? \"isPgUpdateMutationField\"\n : \"isPgDeleteMutationField\"]: true,\n }\n ),\n },\n `Adding ${mode} mutation for ${describePgEntity(\n constraint\n )}`\n );\n });\n }\n return memo;\n }, outerMemo),\n {}\n ),\n `Adding default update/delete mutations to root Mutation type`\n );\n },\n [\"PgMutationUpdateDelete\"]\n );\n}: Plugin);\n"],"file":"PgMutationUpdateDeletePlugin.js"}
|
|
1
|
+
{"version":3,"file":"PgMutationUpdateDeletePlugin.js","names":["_debug","_interopRequireDefault","require","obj","__esModule","default","debug","debugFactory","PgMutationUpdateDeletePlugin","builder","pgDisableDefaultMutations","hook","fields","build","context","newWithHooks","getNodeIdForTypeAndIdentifiers","getTypeAndIdentifiersFromNodeId","nodeIdFieldName","fieldDataGeneratorsByType","extend","parseResolveInfo","getTypeByName","gql2pg","pgGetGqlTypeByTypeIdAndModifier","pgGetGqlInputTypeByTypeIdAndModifier","pgIntrospectionResultsByKind","introspectionResultsByKind","pgSql","sql","graphql","GraphQLNonNull","GraphQLInputObjectType","GraphQLString","GraphQLObjectType","GraphQLID","pgColumnFilter","inflection","pgQueryFromResolveData","queryFromResolveData","pgOmit","omit","pgViaTemporaryTable","viaTemporaryTable","describePgEntity","sqlCommentByAddingTags","pgField","scope","isRootMutation","fieldWithHooks","reduce","outerMemo","mode","class","memo","table","namespace","canUpdate","isUpdatable","attributes","find","attr","canDelete","isDeletable","TableType","type","id","commonCodeRenameMe","pgClient","resolveInfo","getDataFromParsedResolveInfoFragment","PayloadType","args","condition","resolveContext","input","parsedResolveInfoFragment","resolveData","sqlTypeIdentifier","identifier","name","sqlMutationQuery","sqlColumns","sqlValues","inputData","patchField","tableFieldName","forEach","fieldName","column","val","push","typeModifier","length","query","join","map","col","i","fragment","modifiedRowAlias","Symbol","rootValue","row","rows","e","Error","pluralize","_singularizedTableName","clientMutationId","data","uniqueConstraints","constraints","filter","con","Table","tableTypeName","TablePatch","patchType","description","wrapDescription","tableName","deletedNodeIdFieldName","deletedNodeId","Object","assign","addDataGenerator","fieldDataGeneratorsByTableType","get","gens","gen","resolve","__identifiers","isPgMutationPayloadDeletedNodeIdField","__origin","isMutationPayload","isPgUpdatePayloadType","isPgDeletePayloadType","pgIntrospection","primaryKeyConstraint","primaryKeys","keyAttributes","InputType","isPgUpdateInputType","isPgUpdateNodeInputType","isPgDeleteInputType","isPgDeleteNodeInputType","pgInflection","isMutationInput","parent","nodeId","Type","identifiers","key","idx","isPgNodeMutation","pgFieldIntrospection","constraint","keys","every","_","some","typeId","isPgUpdateByKeysInputType","isPgDeleteByKeysInputType","pgKeys","pgFieldConstraint","exports"],"sources":["../../src/plugins/PgMutationUpdateDeletePlugin.js"],"sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\nimport debugFactory from \"debug\";\n\nconst debug = debugFactory(\"graphile-build-pg\");\n\nexport default (async function PgMutationUpdateDeletePlugin(\n builder,\n { pgDisableDefaultMutations }\n) {\n if (pgDisableDefaultMutations) {\n return;\n }\n\n builder.hook(\n \"GraphQLObjectType:fields\",\n (fields, build, context) => {\n const {\n newWithHooks,\n getNodeIdForTypeAndIdentifiers,\n getTypeAndIdentifiersFromNodeId,\n nodeIdFieldName,\n fieldDataGeneratorsByType,\n extend,\n parseResolveInfo,\n getTypeByName,\n gql2pg,\n pgGetGqlTypeByTypeIdAndModifier,\n pgGetGqlInputTypeByTypeIdAndModifier,\n pgIntrospectionResultsByKind: introspectionResultsByKind,\n pgSql: sql,\n graphql: {\n GraphQLNonNull,\n GraphQLInputObjectType,\n GraphQLString,\n GraphQLObjectType,\n GraphQLID,\n },\n pgColumnFilter,\n inflection,\n pgQueryFromResolveData: queryFromResolveData,\n pgOmit: omit,\n pgViaTemporaryTable: viaTemporaryTable,\n describePgEntity,\n sqlCommentByAddingTags,\n pgField,\n } = build;\n const {\n scope: { isRootMutation },\n fieldWithHooks,\n } = context;\n\n if (!isRootMutation) {\n return fields;\n }\n\n return extend(\n fields,\n [\"update\", \"delete\"].reduce(\n (outerMemo, mode) =>\n introspectionResultsByKind.class.reduce((memo, table) => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!table.namespace) return memo;\n const canUpdate =\n mode === \"update\" &&\n table.isUpdatable &&\n !omit(table, \"update\") &&\n // Check at least one attribute is updatable\n table.attributes.find(attr => !omit(attr, \"update\"));\n const canDelete =\n mode === \"delete\" &&\n table.isDeletable &&\n !omit(table, \"delete\");\n if (!canUpdate && !canDelete) return memo;\n\n const TableType = pgGetGqlTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n if (!TableType) {\n return memo;\n }\n async function commonCodeRenameMe(\n pgClient,\n resolveInfo,\n getDataFromParsedResolveInfoFragment,\n PayloadType,\n args,\n condition,\n context,\n resolveContext\n ) {\n const { input } = args;\n const parsedResolveInfoFragment = parseResolveInfo(resolveInfo);\n parsedResolveInfoFragment.args = args; // Allow overriding via makeWrapResolversPlugin\n const resolveData = getDataFromParsedResolveInfoFragment(\n parsedResolveInfoFragment,\n PayloadType\n );\n\n const sqlTypeIdentifier = sql.identifier(\n table.namespace.name,\n table.name\n );\n\n let sqlMutationQuery;\n if (mode === \"update\") {\n const sqlColumns = [];\n const sqlValues = [];\n const inputData =\n input[\n inflection.patchField(inflection.tableFieldName(table))\n ];\n table.attributes.forEach(attr => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!pgColumnFilter(attr, build, context)) return;\n if (omit(attr, \"update\")) return;\n\n const fieldName = inflection.column(attr);\n if (\n fieldName in inputData /* Because we care about null! */\n ) {\n const val = inputData[fieldName];\n sqlColumns.push(sql.identifier(attr.name));\n sqlValues.push(gql2pg(val, attr.type, attr.typeModifier));\n }\n });\n if (sqlColumns.length === 0) {\n return null;\n }\n sqlMutationQuery = sql.query`\\\nupdate ${sql.identifier(table.namespace.name, table.name)} set ${sql.join(\n sqlColumns.map(\n (col, i) => sql.fragment`${col} = ${sqlValues[i]}`\n ),\n \", \"\n )}\nwhere ${condition}\nreturning *`;\n } else {\n sqlMutationQuery = sql.query`\\\ndelete from ${sql.identifier(table.namespace.name, table.name)}\nwhere ${condition}\nreturning *`;\n }\n\n const modifiedRowAlias = sql.identifier(Symbol());\n const query = queryFromResolveData(\n modifiedRowAlias,\n modifiedRowAlias,\n resolveData,\n {},\n null,\n resolveContext,\n resolveInfo.rootValue\n );\n let row;\n try {\n await pgClient.query(\"SAVEPOINT graphql_mutation\");\n const rows = await viaTemporaryTable(\n pgClient,\n sqlTypeIdentifier,\n sqlMutationQuery,\n modifiedRowAlias,\n query\n );\n row = rows[0];\n await pgClient.query(\"RELEASE SAVEPOINT graphql_mutation\");\n } catch (e) {\n await pgClient.query(\n \"ROLLBACK TO SAVEPOINT graphql_mutation\"\n );\n throw e;\n }\n if (!row) {\n throw new Error(\n `No values were ${mode}d in collection '${inflection.pluralize(\n inflection._singularizedTableName(table)\n )}' because no values you can ${mode} were found matching these criteria.`\n );\n }\n return {\n clientMutationId: input.clientMutationId,\n data: row,\n };\n }\n if (TableType) {\n const uniqueConstraints = table.constraints.filter(\n con => con.type === \"u\" || con.type === \"p\"\n );\n const Table = pgGetGqlTypeByTypeIdAndModifier(\n table.type.id,\n null\n );\n const tableTypeName = Table.name;\n const TablePatch = getTypeByName(\n inflection.patchType(Table.name)\n );\n if (mode === \"update\" && !TablePatch) {\n return memo;\n }\n const PayloadType = newWithHooks(\n GraphQLObjectType,\n {\n name: inflection[\n mode === \"delete\"\n ? \"deletePayloadType\"\n : \"updatePayloadType\"\n ](table),\n description: build.wrapDescription(\n `The output of our ${mode} \\`${tableTypeName}\\` mutation.`,\n \"type\"\n ),\n fields: ({ fieldWithHooks }) => {\n const tableName = inflection.tableFieldName(table);\n // This should really be `-node-id` but for compatibility with PostGraphQL v3 we haven't made that change.\n const deletedNodeIdFieldName =\n inflection.deletedNodeId(table);\n return Object.assign(\n {\n clientMutationId: {\n description: build.wrapDescription(\n \"The exact same `clientMutationId` that was provided in the mutation input, unchanged and unused. May be used by a client to track mutations.\",\n \"field\"\n ),\n type: GraphQLString,\n },\n [tableName]: pgField(\n build,\n fieldWithHooks,\n tableName,\n {\n description: build.wrapDescription(\n `The \\`${tableTypeName}\\` that was ${mode}d by this mutation.`,\n \"field\"\n ),\n type: Table,\n },\n {},\n false\n ),\n },\n mode === \"delete\"\n ? {\n [deletedNodeIdFieldName]: fieldWithHooks(\n deletedNodeIdFieldName,\n ({ addDataGenerator }) => {\n const fieldDataGeneratorsByTableType =\n fieldDataGeneratorsByType.get(TableType);\n\n const gens =\n fieldDataGeneratorsByTableType &&\n fieldDataGeneratorsByTableType[\n nodeIdFieldName\n ];\n if (gens) {\n gens.forEach(gen => addDataGenerator(gen));\n }\n return {\n type: GraphQLID,\n resolve(data) {\n return (\n data.data.__identifiers &&\n getNodeIdForTypeAndIdentifiers(\n Table,\n ...data.data.__identifiers\n )\n );\n },\n };\n },\n {\n isPgMutationPayloadDeletedNodeIdField: true,\n }\n ),\n }\n : null\n );\n },\n },\n {\n __origin: `Adding table ${mode} mutation payload type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isMutationPayload: true,\n isPgUpdatePayloadType: mode === \"update\",\n isPgDeletePayloadType: mode === \"delete\",\n pgIntrospection: table,\n }\n );\n\n // NodeId\n const primaryKeyConstraint = table.primaryKeyConstraint;\n if (nodeIdFieldName && primaryKeyConstraint) {\n const primaryKeys =\n primaryKeyConstraint && primaryKeyConstraint.keyAttributes;\n const fieldName =\n inflection[mode === \"update\" ? \"updateNode\" : \"deleteNode\"](\n table\n );\n const InputType = newWithHooks(\n GraphQLInputObjectType,\n {\n description: build.wrapDescription(\n `All input for the \\`${fieldName}\\` mutation.`,\n \"type\"\n ),\n name: inflection[\n mode === \"update\"\n ? \"updateNodeInputType\"\n : \"deleteNodeInputType\"\n ](table),\n fields: Object.assign(\n {\n clientMutationId: {\n description: build.wrapDescription(\n \"An arbitrary string value with no semantic meaning. Will be included in the payload verbatim. May be used to track mutations by the client.\",\n \"field\"\n ),\n type: GraphQLString,\n },\n [nodeIdFieldName]: {\n description: build.wrapDescription(\n `The globally unique \\`ID\\` which will identify a single \\`${tableTypeName}\\` to be ${mode}d.`,\n \"field\"\n ),\n type: new GraphQLNonNull(GraphQLID),\n },\n },\n mode === \"update\" && TablePatch\n ? {\n [inflection.patchField(\n inflection.tableFieldName(table)\n )]: {\n description: build.wrapDescription(\n `An object where the defined keys will be set on the \\`${tableTypeName}\\` being ${mode}d.`,\n \"field\"\n ),\n type: new GraphQLNonNull(TablePatch),\n },\n }\n : null\n ),\n },\n {\n __origin: `Adding table ${mode} (by node ID) mutation input type for ${describePgEntity(\n table\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isPgUpdateInputType: mode === \"update\",\n isPgUpdateNodeInputType: mode === \"update\",\n isPgDeleteInputType: mode === \"delete\",\n isPgDeleteNodeInputType: mode === \"delete\",\n pgInflection: table, // TODO:v5: remove - TYPO!\n pgIntrospection: table,\n isMutationInput: true,\n }\n );\n\n memo = extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n context => {\n const { getDataFromParsedResolveInfoFragment } =\n context;\n return {\n description: build.wrapDescription(\n mode === \"update\"\n ? `Updates a single \\`${tableTypeName}\\` using its globally unique id and a patch.`\n : `Deletes a single \\`${tableTypeName}\\` using its globally unique id.`,\n \"field\"\n ),\n type: PayloadType,\n args: {\n input: {\n type: new GraphQLNonNull(InputType),\n },\n },\n async resolve(\n parent,\n args,\n resolveContext,\n resolveInfo\n ) {\n const { input } = args;\n const { pgClient } = resolveContext;\n const nodeId = input[nodeIdFieldName];\n try {\n const { Type, identifiers } =\n getTypeAndIdentifiersFromNodeId(nodeId);\n if (Type !== TableType) {\n throw new Error(\"Mismatched type\");\n }\n if (identifiers.length !== primaryKeys.length) {\n throw new Error(\"Invalid ID\");\n }\n\n return commonCodeRenameMe(\n pgClient,\n resolveInfo,\n getDataFromParsedResolveInfoFragment,\n PayloadType,\n args,\n sql.fragment`(${sql.join(\n primaryKeys.map(\n (key, idx) =>\n sql.fragment`${sql.identifier(\n key.name\n )} = ${gql2pg(\n identifiers[idx],\n key.type,\n key.typeModifier\n )}`\n ),\n \") and (\"\n )})`,\n context,\n resolveContext\n );\n } catch (e) {\n debug(e);\n return null;\n }\n },\n };\n },\n {\n isPgNodeMutation: true,\n pgFieldIntrospection: table,\n [mode === \"update\"\n ? \"isPgUpdateMutationField\"\n : \"isPgDeleteMutationField\"]: true,\n }\n ),\n },\n \"Adding ${mode} mutation for ${describePgEntity(table)}\"\n );\n }\n\n // Unique\n uniqueConstraints.forEach(constraint => {\n if (omit(constraint, mode)) {\n return;\n }\n const keys = constraint.keyAttributes;\n if (!keys.every(_ => _)) {\n throw new Error(\n `Consistency error: could not find an attribute in the constraint when building the ${mode} mutation for ${describePgEntity(\n table\n )}!`\n );\n }\n if (keys.some(key => omit(key, \"read\"))) {\n return;\n }\n const fieldName = inflection[\n mode === \"update\" ? \"updateByKeys\" : \"deleteByKeys\"\n ](keys, table, constraint);\n const InputType = newWithHooks(\n GraphQLInputObjectType,\n {\n description: build.wrapDescription(\n `All input for the \\`${fieldName}\\` mutation.`,\n \"type\"\n ),\n name: inflection[\n mode === \"update\"\n ? \"updateByKeysInputType\"\n : \"deleteByKeysInputType\"\n ](keys, table, constraint),\n fields: Object.assign(\n {\n clientMutationId: {\n type: GraphQLString,\n },\n },\n mode === \"update\" && TablePatch\n ? {\n [inflection.patchField(\n inflection.tableFieldName(table)\n )]: {\n description: build.wrapDescription(\n `An object where the defined keys will be set on the \\`${tableTypeName}\\` being ${mode}d.`,\n \"field\"\n ),\n type: new GraphQLNonNull(TablePatch),\n },\n }\n : null,\n keys.reduce((memo, key) => {\n memo[inflection.column(key)] = {\n description: key.description,\n type: new GraphQLNonNull(\n pgGetGqlInputTypeByTypeIdAndModifier(\n key.typeId,\n key.typeModifier\n )\n ),\n };\n return memo;\n }, {})\n ),\n },\n {\n __origin: `Adding table ${mode} mutation input type for ${describePgEntity(\n constraint\n )}. You can rename the table's GraphQL type via a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n table,\n {\n name: \"newNameHere\",\n }\n )}`,\n isPgUpdateInputType: mode === \"update\",\n isPgUpdateByKeysInputType: mode === \"update\",\n isPgDeleteInputType: mode === \"delete\",\n isPgDeleteByKeysInputType: mode === \"delete\",\n pgInflection: table, // TODO:v5: remove - TYPO!\n pgIntrospection: table,\n pgKeys: keys,\n isMutationInput: true,\n }\n );\n\n memo = extend(\n memo,\n {\n [fieldName]: fieldWithHooks(\n fieldName,\n context => {\n const { getDataFromParsedResolveInfoFragment } =\n context;\n return {\n description: build.wrapDescription(\n mode === \"update\"\n ? `Updates a single \\`${tableTypeName}\\` using a unique key and a patch.`\n : `Deletes a single \\`${tableTypeName}\\` using a unique key.`,\n \"field\"\n ),\n type: PayloadType,\n args: {\n input: {\n type: new GraphQLNonNull(InputType),\n },\n },\n async resolve(\n parent,\n args,\n resolveContext,\n resolveInfo\n ) {\n const { input } = args;\n const { pgClient } = resolveContext;\n return commonCodeRenameMe(\n pgClient,\n resolveInfo,\n getDataFromParsedResolveInfoFragment,\n PayloadType,\n args,\n sql.fragment`(${sql.join(\n keys.map(\n key =>\n sql.fragment`${sql.identifier(\n key.name\n )} = ${gql2pg(\n input[inflection.column(key)],\n key.type,\n key.typeModifier\n )}`\n ),\n \") and (\"\n )})`,\n context,\n resolveContext\n );\n },\n };\n },\n {\n isPgNodeMutation: false,\n pgFieldIntrospection: table,\n pgFieldConstraint: constraint,\n [mode === \"update\"\n ? \"isPgUpdateMutationField\"\n : \"isPgDeleteMutationField\"]: true,\n }\n ),\n },\n `Adding ${mode} mutation for ${describePgEntity(\n constraint\n )}`\n );\n });\n }\n return memo;\n }, outerMemo),\n {}\n ),\n `Adding default update/delete mutations to root Mutation type`\n );\n },\n [\"PgMutationUpdateDelete\"]\n );\n}: Plugin);\n"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiC,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAEjC,MAAMG,KAAK,GAAG,IAAAC,cAAY,EAAC,mBAAmB,CAAC;AAAC,IAEjBC,4BAA4B,GAA3C,eAAeA,4BAA4BA,CACzDC,OAAO,EACP;EAAEC;AAA0B,CAAC,EAC7B;EACA,IAAIA,yBAAyB,EAAE;IAC7B;EACF;EAEAD,OAAO,CAACE,IAAI,CACV,0BAA0B,EAC1B,CAACC,MAAM,EAAEC,KAAK,EAAEC,OAAO,KAAK;IAC1B,MAAM;MACJC,YAAY;MACZC,8BAA8B;MAC9BC,+BAA+B;MAC/BC,eAAe;MACfC,yBAAyB;MACzBC,MAAM;MACNC,gBAAgB;MAChBC,aAAa;MACbC,MAAM;MACNC,+BAA+B;MAC/BC,oCAAoC;MACpCC,4BAA4B,EAAEC,0BAA0B;MACxDC,KAAK,EAAEC,GAAG;MACVC,OAAO,EAAE;QACPC,cAAc;QACdC,sBAAsB;QACtBC,aAAa;QACbC,iBAAiB;QACjBC;MACF,CAAC;MACDC,cAAc;MACdC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OAAA,GAAAG,4BAAA"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var PgNodeAliasPostGraphile = async function PgNodeAliasPostGraphile(builder) {
|
|
9
8
|
builder.hook("GraphQLObjectType", (object, build, context) => {
|
|
10
9
|
const {
|
|
@@ -13,12 +12,10 @@ var PgNodeAliasPostGraphile = async function PgNodeAliasPostGraphile(builder) {
|
|
|
13
12
|
pluralize
|
|
14
13
|
}
|
|
15
14
|
} = build;
|
|
16
|
-
|
|
17
15
|
if (!setNodeAlias) {
|
|
18
16
|
// Node plugin must be disabled.
|
|
19
17
|
return object;
|
|
20
18
|
}
|
|
21
|
-
|
|
22
19
|
const {
|
|
23
20
|
scope: {
|
|
24
21
|
isPgRowType,
|
|
@@ -26,14 +23,11 @@ var PgNodeAliasPostGraphile = async function PgNodeAliasPostGraphile(builder) {
|
|
|
26
23
|
pgIntrospection: table
|
|
27
24
|
}
|
|
28
25
|
} = context;
|
|
29
|
-
|
|
30
26
|
if (isPgRowType || isPgCompoundType) {
|
|
31
27
|
setNodeAlias(object.name, pluralize(table.name));
|
|
32
28
|
}
|
|
33
|
-
|
|
34
29
|
return object;
|
|
35
30
|
}, ["PgNodeAliasPostGraphile"]);
|
|
36
31
|
};
|
|
37
|
-
|
|
38
32
|
exports.default = PgNodeAliasPostGraphile;
|
|
39
33
|
//# sourceMappingURL=PgNodeAliasPostGraphile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PgNodeAliasPostGraphile.js","names":["PgNodeAliasPostGraphile","builder","hook","object","build","context","setNodeAlias","inflection","pluralize","scope","isPgRowType","isPgCompoundType","pgIntrospection","table","name","exports","default"],"sources":["../../src/plugins/PgNodeAliasPostGraphile.js"],"sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\n\nexport default (async function PgNodeAliasPostGraphile(builder) {\n builder.hook(\n \"GraphQLObjectType\",\n (object, build, context) => {\n const {\n setNodeAlias,\n inflection: { pluralize },\n } = build;\n if (!setNodeAlias) {\n // Node plugin must be disabled.\n return object;\n }\n const {\n scope: { isPgRowType, isPgCompoundType, pgIntrospection: table },\n } = context;\n if (isPgRowType || isPgCompoundType) {\n setNodeAlias(object.name, pluralize(table.name));\n }\n return object;\n },\n [\"PgNodeAliasPostGraphile\"]\n );\n}: Plugin);\n"],"mappings":";;;;;;IAG+BA,uBAAuB,GAAtC,eAAeA,uBAAuBA,CAACC,OAAO,EAAE;EAC9DA,OAAO,CAACC,IAAI,CACV,mBAAmB,EACnB,CAACC,MAAM,EAAEC,KAAK,EAAEC,OAAO,KAAK;IAC1B,MAAM;MACJC,YAAY;MACZC,UAAU,EAAE;QAAEC;MAAU;IAC1B,CAAC,GAAGJ,KAAK;IACT,IAAI,CAACE,YAAY,EAAE;MACjB;MACA,OAAOH,MAAM;IACf;IACA,MAAM;MACJM,KAAK,EAAE;QAAEC,WAAW;QAAEC,gBAAgB;QAAEC,eAAe,EAAEC;MAAM;IACjE,CAAC,GAAGR,OAAO;IACX,IAAIK,WAAW,IAAIC,gBAAgB,EAAE;MACnCL,YAAY,CAACH,MAAM,CAACW,IAAI,EAAEN,SAAS,CAACK,KAAK,CAACC,IAAI,CAAC,CAAC;IAClD;IACA,OAAOX,MAAM;EACf,CAAC,EACD,CAAC,yBAAyB,CAC5B,CAAC;AACH,CAAC;AAAAY,OAAA,CAAAC,OAAA,GAAAhB,uBAAA"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var PgOrderAllColumnsPlugin = function PgOrderAllColumnsPlugin(builder) {
|
|
9
8
|
builder.hook("GraphQLEnumType:values", (values, build, context) => {
|
|
10
9
|
const {
|
|
@@ -21,11 +20,9 @@ var PgOrderAllColumnsPlugin = function PgOrderAllColumnsPlugin(builder) {
|
|
|
21
20
|
pgIntrospection: table
|
|
22
21
|
}
|
|
23
22
|
} = context;
|
|
24
|
-
|
|
25
23
|
if (!isPgRowSortEnum || !table || table.kind !== "class") {
|
|
26
24
|
return values;
|
|
27
25
|
}
|
|
28
|
-
|
|
29
26
|
return extend(values, table.attributes.reduce((memo, attr) => {
|
|
30
27
|
// PERFORMANCE: These used to be .filter(...) calls
|
|
31
28
|
if (!pgColumnFilter(attr, build, context)) return memo;
|
|
@@ -59,6 +56,5 @@ var PgOrderAllColumnsPlugin = function PgOrderAllColumnsPlugin(builder) {
|
|
|
59
56
|
}, {}), `Adding order values from table '${table.name}'`);
|
|
60
57
|
}, ["PgOrderAllColumns"]);
|
|
61
58
|
};
|
|
62
|
-
|
|
63
59
|
exports.default = PgOrderAllColumnsPlugin;
|
|
64
60
|
//# sourceMappingURL=PgOrderAllColumnsPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"PgOrderAllColumnsPlugin.js","names":["PgOrderAllColumnsPlugin","builder","hook","values","build","context","extend","pgColumnFilter","inflection","pgOmit","omit","describePgEntity","sqlCommentByAddingTags","scope","isPgRowSortEnum","pgIntrospection","table","kind","attributes","reduce","memo","attr","unique","isUnique","ascFieldName","orderByColumnEnum","descFieldName","value","alias","toLowerCase","specs","name","exports","default"],"sources":["../../src/plugins/PgOrderAllColumnsPlugin.js"],"sourcesContent":["// @flow\nimport type { Plugin } from \"graphile-build\";\n\nexport default (function PgOrderAllColumnsPlugin(builder) {\n builder.hook(\n \"GraphQLEnumType:values\",\n (values, build, context) => {\n const {\n extend,\n pgColumnFilter,\n inflection,\n pgOmit: omit,\n describePgEntity,\n sqlCommentByAddingTags,\n } = build;\n const {\n scope: { isPgRowSortEnum, pgIntrospection: table },\n } = context;\n if (!isPgRowSortEnum || !table || table.kind !== \"class\") {\n return values;\n }\n return extend(\n values,\n table.attributes.reduce((memo, attr) => {\n // PERFORMANCE: These used to be .filter(...) calls\n if (!pgColumnFilter(attr, build, context)) return memo;\n if (omit(attr, \"order\")) return memo;\n const unique = attr.isUnique;\n\n const ascFieldName = inflection.orderByColumnEnum(attr, true);\n const descFieldName = inflection.orderByColumnEnum(attr, false);\n memo = extend(\n memo,\n {\n [ascFieldName]: {\n value: {\n alias: ascFieldName.toLowerCase(),\n specs: [[attr.name, true]],\n unique,\n },\n },\n },\n `Adding ascending orderBy enum value for ${describePgEntity(\n attr\n )}. You can rename this field with a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n attr,\n {\n name: \"newNameHere\",\n }\n )}`\n );\n memo = extend(\n memo,\n {\n [descFieldName]: {\n value: {\n alias: descFieldName.toLowerCase(),\n specs: [[attr.name, false]],\n unique,\n },\n },\n },\n `Adding descending orderBy enum value for ${describePgEntity(\n attr\n )}. You can rename this field with a 'Smart Comment':\\n\\n ${sqlCommentByAddingTags(\n attr,\n {\n name: \"newNameHere\",\n }\n )}`\n );\n return memo;\n }, {}),\n `Adding order values from table '${table.name}'`\n );\n },\n [\"PgOrderAllColumns\"]\n );\n}: Plugin);\n"],"mappings":";;;;;;IAGyBA,uBAAuB,GAAhC,SAASA,uBAAuBA,CAACC,OAAO,EAAE;EACxDA,OAAO,CAACC,IAAI,CACV,wBAAwB,EACxB,CAACC,MAAM,EAAEC,KAAK,EAAEC,OAAO,KAAK;IAC1B,MAAM;MACJC,MAAM;MACNC,cAAc;MACdC,UAAU;MACVC,MAAM,EAAEC,IAAI;MACZC,gBAAgB;MAChBC;IACF,CAAC,GAAGR,KAAK;IACT,MAAM;MACJS,KAAK,EAAE;QAAEC,eAAe;QAAEC,eAAe,EAAEC;MAAM;IACnD,CAAC,GAAGX,OAAO;IACX,IAAI,CAACS,eAAe,IAAI,CAACE,KAAK,IAAIA,KAAK,CAACC,IAAI,KAAK,OAAO,EAAE;MACxD,OAAOd,MAAM;IACf;IACA,OAAOG,MAAM,CACX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L,mCAAkCJ,KAAK,CAACe,IAAK,GAChD,CAAC;EACH,CAAC,EACD,CAAC,mBAAmB,CACtB,CAAC;AACH,CAAC;AAAAC,OAAA,CAAAC,OAAA,GAAAjC,uBAAA"}
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var PgOrderByPrimaryKeyPlugin = function PgOrderByPrimaryKeyPlugin(builder) {
|
|
9
8
|
builder.hook("GraphQLEnumType:values", (values, build, context) => {
|
|
10
9
|
const {
|
|
@@ -17,17 +16,13 @@ var PgOrderByPrimaryKeyPlugin = function PgOrderByPrimaryKeyPlugin(builder) {
|
|
|
17
16
|
pgIntrospection: table
|
|
18
17
|
}
|
|
19
18
|
} = context;
|
|
20
|
-
|
|
21
19
|
if (!isPgRowSortEnum || !table || table.kind !== "class") {
|
|
22
20
|
return values;
|
|
23
21
|
}
|
|
24
|
-
|
|
25
22
|
const primaryKeyConstraint = table.primaryKeyConstraint;
|
|
26
|
-
|
|
27
23
|
if (!primaryKeyConstraint) {
|
|
28
24
|
return values;
|
|
29
25
|
}
|
|
30
|
-
|
|
31
26
|
const primaryKeys = primaryKeyConstraint.keyAttributes;
|
|
32
27
|
return extend(values, {
|
|
33
28
|
[inflection.builtin("PRIMARY_KEY_ASC")]: {
|
|
@@ -47,6 +42,5 @@ var PgOrderByPrimaryKeyPlugin = function PgOrderByPrimaryKeyPlugin(builder) {
|
|
|
47
42
|
}, `Adding primary key asc/desc sort to table '${table.name}'`);
|
|
48
43
|
}, ["PgOrderByPrimaryKey"]);
|
|
49
44
|
};
|
|
50
|
-
|
|
51
45
|
exports.default = PgOrderByPrimaryKeyPlugin;
|
|
52
46
|
//# sourceMappingURL=PgOrderByPrimaryKeyPlugin.js.map
|