@platformatic/sql-graphql 3.72.0 → 4.0.0-alpha.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/lib/entity-to-type.js +54 -8
- package/package.json +8 -8
- package/.npmignore +0 -2
package/lib/entity-to-type.js
CHANGED
|
@@ -304,32 +304,78 @@ export function constructGraph (app, entity, opts, ignore) {
|
|
|
304
304
|
|
|
305
305
|
// Views are read-only: skip all mutations
|
|
306
306
|
if (!entity.isView) {
|
|
307
|
-
|
|
307
|
+
// Preserve the existing bulk mutation name for uncountable entity names
|
|
308
|
+
// (for example, insertSheep) and give the singular operation a clear
|
|
309
|
+
// fallback name so the two fields do not overwrite each other.
|
|
310
|
+
const insert = singular === plural ? camelcase(['insertOne', singular]) : camelcase(['insert', singular])
|
|
308
311
|
|
|
309
|
-
mutationTopFields[
|
|
312
|
+
mutationTopFields[insert] = {
|
|
310
313
|
type,
|
|
311
314
|
args: {
|
|
312
315
|
input: { type: new GraphQLNonNull(inputType) }
|
|
313
316
|
}
|
|
314
317
|
}
|
|
315
318
|
|
|
316
|
-
resolvers.Mutation[
|
|
319
|
+
resolvers.Mutation[insert] = async (_, { input }, ctx, info) => {
|
|
317
320
|
const fields = fromSelectionSet(info.fieldNodes[0].selectionSet)
|
|
318
|
-
return entity.
|
|
321
|
+
return entity.insert({ input, ctx, fields: [...fields, ...relationalFields] })
|
|
319
322
|
}
|
|
320
323
|
|
|
321
|
-
const
|
|
324
|
+
const insertMany = camelcase(['insert', plural])
|
|
322
325
|
|
|
323
|
-
mutationTopFields[
|
|
326
|
+
mutationTopFields[insertMany] = {
|
|
324
327
|
type: new GraphQLList(type),
|
|
325
328
|
args: {
|
|
326
329
|
inputs: { type: new GraphQLNonNull(new GraphQLList(inputType)) }
|
|
327
330
|
}
|
|
328
331
|
}
|
|
329
332
|
|
|
330
|
-
resolvers.Mutation[
|
|
333
|
+
resolvers.Mutation[insertMany] = (_, { inputs }, ctx, info) => {
|
|
334
|
+
const fields = fromSelectionSet(info.fieldNodes[0].selectionSet)
|
|
335
|
+
return entity.insertMany({ inputs, ctx, fields: [...fields, ...relationalFields] })
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
const update = camelcase(['update', singular])
|
|
339
|
+
|
|
340
|
+
mutationTopFields[update] = {
|
|
341
|
+
type,
|
|
342
|
+
args: {
|
|
343
|
+
input: { type: new GraphQLNonNull(inputType) }
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
resolvers.Mutation[update] = async (_, { input }, ctx, info) => {
|
|
348
|
+
const fields = fromSelectionSet(info.fieldNodes[0].selectionSet)
|
|
349
|
+
return entity.update({ input, ctx, fields: [...fields, ...relationalFields] })
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
const upsert = camelcase(['upsert', singular])
|
|
353
|
+
|
|
354
|
+
mutationTopFields[upsert] = {
|
|
355
|
+
type,
|
|
356
|
+
args: {
|
|
357
|
+
input: { type: new GraphQLNonNull(inputType) }
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
resolvers.Mutation[upsert] = async (_, { input }, ctx, info) => {
|
|
362
|
+
const fields = fromSelectionSet(info.fieldNodes[0].selectionSet)
|
|
363
|
+
return entity.upsert({ input, ctx, fields: [...fields, ...relationalFields] })
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
const save = camelcase(['save', singular])
|
|
367
|
+
|
|
368
|
+
mutationTopFields[save] = {
|
|
369
|
+
type,
|
|
370
|
+
deprecationReason: `Use ${upsert} instead.`,
|
|
371
|
+
args: {
|
|
372
|
+
input: { type: new GraphQLNonNull(inputType) }
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
resolvers.Mutation[save] = async (_, { input }, ctx, info) => {
|
|
331
377
|
const fields = fromSelectionSet(info.fieldNodes[0].selectionSet)
|
|
332
|
-
return entity.
|
|
378
|
+
return entity.save({ input, ctx, fields: [...fields, ...relationalFields] })
|
|
333
379
|
}
|
|
334
380
|
|
|
335
381
|
const deleteKey = camelcase(['delete', plural])
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-graphql",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.1",
|
|
4
4
|
"description": "Map SQL dbs to GraphQL",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -18,9 +18,6 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@matteo.collina/snap": "^0.3.0",
|
|
20
20
|
"@mercuriusjs/gateway": "^5.0.0",
|
|
21
|
-
"@platformatic/sql-events": "3.72.0",
|
|
22
|
-
"@platformatic/sql-mapper": "3.72.0",
|
|
23
|
-
"@platformatic/telemetry": "3.72.0",
|
|
24
21
|
"cleaner-spec-reporter": "^0.5.0",
|
|
25
22
|
"eslint": "9",
|
|
26
23
|
"fastify": "^5.0.0",
|
|
@@ -29,22 +26,25 @@
|
|
|
29
26
|
"tstyche": "^7.0.0",
|
|
30
27
|
"typescript": "~6.0.3",
|
|
31
28
|
"why-is-node-running": "^2.2.2",
|
|
32
|
-
"ws": "^8.16.0"
|
|
29
|
+
"ws": "^8.16.0",
|
|
30
|
+
"@platformatic/sql-events": "4.0.0-alpha.1",
|
|
31
|
+
"@platformatic/sql-mapper": "4.0.0-alpha.1",
|
|
32
|
+
"@platformatic/tracing": "4.0.0-alpha.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@fastify/error": "^4.0.0",
|
|
36
36
|
"@mercuriusjs/federation": "^5.0.0",
|
|
37
|
-
"@platformatic/foundation": "3.72.0",
|
|
38
37
|
"camelcase": "^6.3.0",
|
|
39
38
|
"fastify-plugin": "^6.0.0",
|
|
40
39
|
"graphql": "^16.8.1",
|
|
41
40
|
"graphql-scalars": "^1.22.5",
|
|
42
41
|
"graphql-type-json": "^0.3.2",
|
|
43
42
|
"inflected": "^2.1.0",
|
|
44
|
-
"mercurius": "^16.0.0"
|
|
43
|
+
"mercurius": "^16.0.0",
|
|
44
|
+
"@platformatic/foundation": "4.0.0-alpha.1"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
|
-
"node": ">=
|
|
47
|
+
"node": ">=24.20.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"lint": "eslint",
|
package/.npmignore
DELETED