@smartive/graphql-magic 19.2.0-next.1 → 19.2.0-next.3
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/CHANGELOG.md +3 -3
- package/dist/bin/gqm.cjs +1 -0
- package/dist/cjs/index.cjs +98 -68
- package/dist/esm/models/mutation-hook.d.ts +2 -1
- package/dist/esm/models/utils.js +1 -0
- package/dist/esm/models/utils.js.map +1 -1
- package/dist/esm/resolvers/mutations.d.ts +8 -7
- package/dist/esm/resolvers/mutations.js +95 -68
- package/dist/esm/resolvers/mutations.js.map +1 -1
- package/package.json +1 -1
- package/src/models/mutation-hook.ts +3 -1
- package/src/models/utils.ts +1 -0
- package/src/resolvers/mutations.ts +119 -77
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# [19.2.0-next.
|
|
1
|
+
# [19.2.0-next.3](https://github.com/smartive/graphql-magic/compare/v19.2.0-next.2...v19.2.0-next.3) (2025-06-18)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* Just model name in utility functions ([c7bfdff](https://github.com/smartive/graphql-magic/commit/c7bfdff421ea09b3a4db0bc32971b4a67a365b18))
|
package/dist/bin/gqm.cjs
CHANGED
package/dist/cjs/index.cjs
CHANGED
|
@@ -179,6 +179,7 @@ __export(index_exports, {
|
|
|
179
179
|
queryRelations: () => queryRelations,
|
|
180
180
|
queryResolver: () => queryResolver,
|
|
181
181
|
resolve: () => resolve,
|
|
182
|
+
restoreEntity: () => restoreEntity,
|
|
182
183
|
retry: () => retry,
|
|
183
184
|
scalar: () => scalar,
|
|
184
185
|
summon: () => summon,
|
|
@@ -794,6 +795,7 @@ var get = (object2, key) => {
|
|
|
794
795
|
if (value2 === void 0 || value2 === null) {
|
|
795
796
|
const error = new Error(`Object doesn't have ${String(key)}`);
|
|
796
797
|
console.warn(error);
|
|
798
|
+
console.trace();
|
|
797
799
|
throw error;
|
|
798
800
|
}
|
|
799
801
|
return value2;
|
|
@@ -2668,28 +2670,31 @@ var mutationResolver = async (_parent, args2, partialCtx, info) => {
|
|
|
2668
2670
|
return await partialCtx.knex.transaction(async (knex) => {
|
|
2669
2671
|
const [, mutation, modelName] = it(info.fieldName.match(/^(create|update|delete|restore)(.+)$/));
|
|
2670
2672
|
const ctx = { ...partialCtx, knex, info, aliases: new AliasGenerator() };
|
|
2671
|
-
const model = ctx.models.getModel(modelName, "entity");
|
|
2672
2673
|
switch (mutation) {
|
|
2673
2674
|
case "create": {
|
|
2674
|
-
const id = await createEntity(
|
|
2675
|
+
const id = await createEntity(modelName, args2.data, ctx, "mutation");
|
|
2675
2676
|
return await resolve(ctx, id);
|
|
2676
2677
|
}
|
|
2677
2678
|
case "update": {
|
|
2678
2679
|
const id = args2.where.id;
|
|
2679
|
-
await updateEntity(
|
|
2680
|
+
await updateEntity(modelName, id, args2.data, ctx);
|
|
2680
2681
|
return await resolve(ctx, id);
|
|
2681
2682
|
}
|
|
2682
2683
|
case "delete": {
|
|
2683
2684
|
const id = args2.where.id;
|
|
2684
|
-
await deleteEntity(
|
|
2685
|
-
return
|
|
2685
|
+
await deleteEntity(modelName, id, args2.dryRun, void 0, void 0, ctx, "mutation");
|
|
2686
|
+
return id;
|
|
2687
|
+
}
|
|
2688
|
+
case "restore": {
|
|
2689
|
+
const id = args2.where.id;
|
|
2690
|
+
await restoreEntity(modelName, id, ctx, "mutation");
|
|
2691
|
+
return id;
|
|
2686
2692
|
}
|
|
2687
|
-
case "restore":
|
|
2688
|
-
return await restoreEntity(model, args2.where.id, ctx);
|
|
2689
2693
|
}
|
|
2690
2694
|
});
|
|
2691
2695
|
};
|
|
2692
|
-
var createEntity = async (
|
|
2696
|
+
var createEntity = async (modelName, input2, ctx, trigger = "direct-call") => {
|
|
2697
|
+
const model = ctx.models.getModel(modelName, "entity");
|
|
2693
2698
|
const normalizedInput = { ...input2 };
|
|
2694
2699
|
if (!normalizedInput.id) {
|
|
2695
2700
|
normalizedInput.id = (0, import_uuid.v4)();
|
|
@@ -2708,63 +2713,79 @@ var createEntity = async (model, input2, ctx) => {
|
|
|
2708
2713
|
await checkCanWrite(ctx, model, normalizedInput, "CREATE");
|
|
2709
2714
|
await ctx.handleUploads?.(normalizedInput);
|
|
2710
2715
|
const data = { prev: {}, input: input2, normalizedInput, next: normalizedInput };
|
|
2711
|
-
await ctx.mutationHook?.({ model, action: "create", trigger
|
|
2712
|
-
await createEntity(model, normalizedInput, ctx);
|
|
2716
|
+
await ctx.mutationHook?.({ model, action: "create", trigger, when: "before", data, ctx });
|
|
2713
2717
|
if (model.parent) {
|
|
2714
2718
|
const rootInput = {};
|
|
2715
2719
|
const childInput = { id };
|
|
2716
2720
|
for (const field of model.fields) {
|
|
2717
2721
|
const columnName = field.kind === "relation" ? `${field.name}Id` : field.name;
|
|
2718
|
-
if (columnName in
|
|
2722
|
+
if (columnName in normalizedInput) {
|
|
2719
2723
|
if (field.inherited) {
|
|
2720
|
-
rootInput[columnName] =
|
|
2724
|
+
rootInput[columnName] = normalizedInput[columnName];
|
|
2721
2725
|
} else {
|
|
2722
|
-
childInput[columnName] =
|
|
2726
|
+
childInput[columnName] = normalizedInput[columnName];
|
|
2723
2727
|
}
|
|
2724
2728
|
}
|
|
2725
2729
|
}
|
|
2726
2730
|
await ctx.knex(model.parent).insert(rootInput);
|
|
2727
2731
|
await ctx.knex(model.name).insert(childInput);
|
|
2728
2732
|
} else {
|
|
2729
|
-
await ctx.knex(model.name).insert(
|
|
2733
|
+
await ctx.knex(model.name).insert(normalizedInput);
|
|
2730
2734
|
}
|
|
2731
|
-
await createRevision(model,
|
|
2732
|
-
await ctx.mutationHook?.({ model, action: "create", trigger
|
|
2735
|
+
await createRevision(model, normalizedInput, ctx);
|
|
2736
|
+
await ctx.mutationHook?.({ model, action: "create", trigger, when: "after", data, ctx });
|
|
2733
2737
|
return normalizedInput.id;
|
|
2734
2738
|
};
|
|
2735
|
-
var updateEntities = async (
|
|
2736
|
-
const entities = await ctx.knex(
|
|
2739
|
+
var updateEntities = async (modelName, where, updateFields, ctx) => {
|
|
2740
|
+
const entities = await ctx.knex(modelName).where(where).select("id");
|
|
2737
2741
|
for (const entity of entities) {
|
|
2738
|
-
await updateEntity(
|
|
2742
|
+
await updateEntity(modelName, entity.id, updateFields, ctx);
|
|
2739
2743
|
}
|
|
2740
2744
|
};
|
|
2741
|
-
var updateEntity = async (
|
|
2745
|
+
var updateEntity = async (modelName, id, input2, ctx, trigger = "direct-call") => {
|
|
2746
|
+
const model = ctx.models.getModel(modelName, "entity");
|
|
2742
2747
|
const normalizedInput = { ...input2 };
|
|
2743
2748
|
sanitize(ctx, model, normalizedInput);
|
|
2744
|
-
const
|
|
2749
|
+
const currentEntity = await getEntityToMutate(ctx, model, { id }, "UPDATE");
|
|
2745
2750
|
for (const key of Object.keys(normalizedInput)) {
|
|
2746
|
-
if (normalizedInput[key] ===
|
|
2751
|
+
if (normalizedInput[key] === currentEntity[key]) {
|
|
2747
2752
|
delete normalizedInput[key];
|
|
2748
2753
|
}
|
|
2749
2754
|
}
|
|
2750
2755
|
if (Object.keys(normalizedInput).length > 0) {
|
|
2751
2756
|
await checkCanWrite(ctx, model, normalizedInput, "UPDATE");
|
|
2752
2757
|
await ctx.handleUploads?.(normalizedInput);
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
+
await ctx.mutationHook?.({
|
|
2759
|
+
model,
|
|
2760
|
+
action: "update",
|
|
2761
|
+
trigger,
|
|
2762
|
+
when: "before",
|
|
2763
|
+
data: { prev: currentEntity, input: input2, normalizedInput, next: { ...currentEntity, ...normalizedInput } },
|
|
2764
|
+
ctx
|
|
2765
|
+
});
|
|
2766
|
+
await doUpdate(model, currentEntity, normalizedInput, ctx);
|
|
2767
|
+
await ctx.mutationHook?.({
|
|
2768
|
+
model,
|
|
2769
|
+
action: "update",
|
|
2770
|
+
trigger,
|
|
2771
|
+
when: "after",
|
|
2772
|
+
data: { prev: currentEntity, input: input2, normalizedInput, next: { ...currentEntity, ...normalizedInput } },
|
|
2773
|
+
ctx
|
|
2774
|
+
});
|
|
2758
2775
|
}
|
|
2759
2776
|
};
|
|
2760
|
-
var deleteEntities = async (
|
|
2761
|
-
const entities = await ctx.knex(
|
|
2777
|
+
var deleteEntities = async (modelName, where, deleteRootType, deleteRootId, ctx) => {
|
|
2778
|
+
const entities = await ctx.knex(modelName).where(where).select("id");
|
|
2762
2779
|
for (const entity of entities) {
|
|
2763
|
-
await deleteEntity(
|
|
2780
|
+
await deleteEntity(modelName, entity.id, false, deleteRootType, deleteRootId, ctx);
|
|
2764
2781
|
}
|
|
2765
2782
|
};
|
|
2766
|
-
var deleteEntity = async (
|
|
2783
|
+
var deleteEntity = async (modelName, id, dryRun, deleteRootType, deleteRootId = id, ctx, trigger = "direct-call") => {
|
|
2784
|
+
const model = ctx.models.getModel(modelName, "entity");
|
|
2767
2785
|
const rootModel = model.rootModel;
|
|
2786
|
+
if (!deleteRootType) {
|
|
2787
|
+
deleteRootType = rootModel.name;
|
|
2788
|
+
}
|
|
2768
2789
|
const entity = await getEntityToMutate(ctx, rootModel, { id }, "DELETE");
|
|
2769
2790
|
if (entity.deleted) {
|
|
2770
2791
|
throw new ForbiddenError(`${getTechnicalDisplay(model, entity)} is already deleted.`);
|
|
@@ -2776,7 +2797,7 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2776
2797
|
const mutations = [];
|
|
2777
2798
|
const afterHooks = [];
|
|
2778
2799
|
const mutationHook = ctx.mutationHook;
|
|
2779
|
-
const deleteCascade = async (currentModel, currentEntity) => {
|
|
2800
|
+
const deleteCascade = async (currentModel, currentEntity, currentTrigger) => {
|
|
2780
2801
|
if (!(currentModel.name in toDelete)) {
|
|
2781
2802
|
toDelete[currentModel.name] = {};
|
|
2782
2803
|
}
|
|
@@ -2784,7 +2805,6 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2784
2805
|
return;
|
|
2785
2806
|
}
|
|
2786
2807
|
toDelete[currentModel.name][currentEntity.id] = await fetchDisplay(ctx.knex, currentModel, currentEntity);
|
|
2787
|
-
const trigger = currentModel.name === rootModel.name && currentEntity.id === entity.id ? "mutation" : "cascade";
|
|
2788
2808
|
if (!dryRun) {
|
|
2789
2809
|
const normalizedInput = {
|
|
2790
2810
|
deleted: true,
|
|
@@ -2793,31 +2813,29 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2793
2813
|
deleteRootType,
|
|
2794
2814
|
deleteRootId
|
|
2795
2815
|
};
|
|
2796
|
-
const next = { ...currentEntity, ...normalizedInput };
|
|
2797
|
-
const data = { prev: currentEntity, input: {}, normalizedInput, next };
|
|
2798
2816
|
if (mutationHook) {
|
|
2799
2817
|
beforeHooks.push(async () => {
|
|
2800
2818
|
await mutationHook({
|
|
2801
2819
|
model: currentModel,
|
|
2802
2820
|
action: "delete",
|
|
2803
|
-
trigger,
|
|
2821
|
+
trigger: currentTrigger,
|
|
2804
2822
|
when: "before",
|
|
2805
|
-
data,
|
|
2823
|
+
data: { prev: currentEntity, input: {}, normalizedInput, next: { ...currentEntity, ...normalizedInput } },
|
|
2806
2824
|
ctx
|
|
2807
2825
|
});
|
|
2808
2826
|
});
|
|
2809
2827
|
}
|
|
2810
2828
|
mutations.push(async () => {
|
|
2811
|
-
await doUpdate(currentModel,
|
|
2829
|
+
await doUpdate(currentModel, currentEntity, normalizedInput, ctx);
|
|
2812
2830
|
});
|
|
2813
2831
|
if (mutationHook) {
|
|
2814
2832
|
afterHooks.push(async () => {
|
|
2815
2833
|
await mutationHook({
|
|
2816
2834
|
model: currentModel,
|
|
2817
2835
|
action: "delete",
|
|
2818
|
-
trigger,
|
|
2836
|
+
trigger: currentTrigger,
|
|
2819
2837
|
when: "after",
|
|
2820
|
-
data,
|
|
2838
|
+
data: { prev: currentEntity, input: {}, normalizedInput, next: { ...currentEntity, ...normalizedInput } },
|
|
2821
2839
|
ctx
|
|
2822
2840
|
});
|
|
2823
2841
|
});
|
|
@@ -2846,8 +2864,6 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2846
2864
|
toUnlink[descendantModel.name][descendant.id].fields.push(name2);
|
|
2847
2865
|
} else {
|
|
2848
2866
|
const normalizedInput = { [`${name2}Id`]: null };
|
|
2849
|
-
const next = { ...descendant, ...normalizedInput };
|
|
2850
|
-
const data = { prev: descendant, input: {}, normalizedInput, next };
|
|
2851
2867
|
if (mutationHook) {
|
|
2852
2868
|
beforeHooks.push(async () => {
|
|
2853
2869
|
await mutationHook({
|
|
@@ -2855,13 +2871,13 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2855
2871
|
action: "update",
|
|
2856
2872
|
trigger: "set-null",
|
|
2857
2873
|
when: "before",
|
|
2858
|
-
data,
|
|
2874
|
+
data: { prev: descendant, input: {}, normalizedInput, next: { ...descendant, ...normalizedInput } },
|
|
2859
2875
|
ctx
|
|
2860
2876
|
});
|
|
2861
2877
|
});
|
|
2862
2878
|
}
|
|
2863
2879
|
mutations.push(async () => {
|
|
2864
|
-
await doUpdate(descendantModel,
|
|
2880
|
+
await doUpdate(descendantModel, descendant, normalizedInput, ctx);
|
|
2865
2881
|
});
|
|
2866
2882
|
if (mutationHook) {
|
|
2867
2883
|
afterHooks.push(async () => {
|
|
@@ -2870,7 +2886,7 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2870
2886
|
action: "update",
|
|
2871
2887
|
trigger: "set-null",
|
|
2872
2888
|
when: "after",
|
|
2873
|
-
data,
|
|
2889
|
+
data: { prev: descendant, input: {}, normalizedInput, next: { ...descendant, ...normalizedInput } },
|
|
2874
2890
|
ctx
|
|
2875
2891
|
});
|
|
2876
2892
|
});
|
|
@@ -2916,7 +2932,7 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2916
2932
|
);
|
|
2917
2933
|
}
|
|
2918
2934
|
for (const descendant of descendants) {
|
|
2919
|
-
await deleteCascade(descendantModel, descendant);
|
|
2935
|
+
await deleteCascade(descendantModel, descendant, "cascade");
|
|
2920
2936
|
}
|
|
2921
2937
|
break;
|
|
2922
2938
|
}
|
|
@@ -2924,7 +2940,7 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2924
2940
|
}
|
|
2925
2941
|
}
|
|
2926
2942
|
};
|
|
2927
|
-
await deleteCascade(rootModel, entity);
|
|
2943
|
+
await deleteCascade(rootModel, entity, trigger);
|
|
2928
2944
|
for (const callback of [...beforeHooks, ...mutations, ...afterHooks]) {
|
|
2929
2945
|
await callback();
|
|
2930
2946
|
}
|
|
@@ -2936,9 +2952,9 @@ var deleteEntity = async (model, id, dryRun, deleteRootType, deleteRootId, ctx)
|
|
|
2936
2952
|
restricted
|
|
2937
2953
|
});
|
|
2938
2954
|
}
|
|
2939
|
-
return entity.id;
|
|
2940
2955
|
};
|
|
2941
|
-
var restoreEntity = async (
|
|
2956
|
+
var restoreEntity = async (modelName, id, ctx, trigger = "direct-call") => {
|
|
2957
|
+
const model = ctx.models.getModel(modelName, "entity");
|
|
2942
2958
|
const rootModel = model.rootModel;
|
|
2943
2959
|
const entity = await getEntityToMutate(ctx, rootModel, { id }, "RESTORE");
|
|
2944
2960
|
if (!entity.deleted) {
|
|
@@ -2955,7 +2971,7 @@ var restoreEntity = async (model, id, ctx) => {
|
|
|
2955
2971
|
const beforeHooks = [];
|
|
2956
2972
|
const mutations = [];
|
|
2957
2973
|
const afterHooks = [];
|
|
2958
|
-
const restoreCascade = async (currentModel, currentEntity) => {
|
|
2974
|
+
const restoreCascade = async (currentModel, currentEntity, currentTrigger) => {
|
|
2959
2975
|
if (entity.deleteRootId) {
|
|
2960
2976
|
if (!(currentEntity.deleteRootType === model.name && currentEntity.deleteRootId === entity.id)) {
|
|
2961
2977
|
return;
|
|
@@ -2992,15 +3008,29 @@ var restoreEntity = async (model, id, ctx) => {
|
|
|
2992
3008
|
const data = { prev: currentEntity, input: {}, normalizedInput, next: { ...currentEntity, ...normalizedInput } };
|
|
2993
3009
|
if (ctx.mutationHook) {
|
|
2994
3010
|
beforeHooks.push(async () => {
|
|
2995
|
-
await ctx.mutationHook({
|
|
3011
|
+
await ctx.mutationHook({
|
|
3012
|
+
model: currentModel,
|
|
3013
|
+
action: "restore",
|
|
3014
|
+
trigger: currentTrigger,
|
|
3015
|
+
when: "before",
|
|
3016
|
+
data,
|
|
3017
|
+
ctx
|
|
3018
|
+
});
|
|
2996
3019
|
});
|
|
2997
3020
|
}
|
|
2998
3021
|
mutations.push(async () => {
|
|
2999
|
-
await doUpdate(currentModel,
|
|
3022
|
+
await doUpdate(currentModel, currentEntity, normalizedInput, ctx);
|
|
3000
3023
|
});
|
|
3001
3024
|
if (ctx.mutationHook) {
|
|
3002
3025
|
afterHooks.push(async () => {
|
|
3003
|
-
await ctx.mutationHook({
|
|
3026
|
+
await ctx.mutationHook({
|
|
3027
|
+
model: currentModel,
|
|
3028
|
+
action: "restore",
|
|
3029
|
+
trigger: currentTrigger,
|
|
3030
|
+
when: "after",
|
|
3031
|
+
data,
|
|
3032
|
+
ctx
|
|
3033
|
+
});
|
|
3004
3034
|
});
|
|
3005
3035
|
}
|
|
3006
3036
|
for (const {
|
|
@@ -3020,15 +3050,14 @@ var restoreEntity = async (model, id, ctx) => {
|
|
|
3020
3050
|
);
|
|
3021
3051
|
}
|
|
3022
3052
|
for (const descendant of deletedDescendants) {
|
|
3023
|
-
await restoreCascade(descendantModel, descendant);
|
|
3053
|
+
await restoreCascade(descendantModel, descendant, "cascade");
|
|
3024
3054
|
}
|
|
3025
3055
|
}
|
|
3026
3056
|
};
|
|
3027
|
-
await restoreCascade(rootModel, entity);
|
|
3057
|
+
await restoreCascade(rootModel, entity, trigger);
|
|
3028
3058
|
for (const callback of [...beforeHooks, ...mutations, ...afterHooks]) {
|
|
3029
3059
|
await callback();
|
|
3030
3060
|
}
|
|
3031
|
-
return id;
|
|
3032
3061
|
};
|
|
3033
3062
|
var createRevision = async (model, data, ctx) => {
|
|
3034
3063
|
if (model.updatable) {
|
|
@@ -3095,13 +3124,13 @@ var sanitize = (ctx, model, data) => {
|
|
|
3095
3124
|
};
|
|
3096
3125
|
var isEndOfDay = (field) => isPrimitive(field) && field.type === "DateTime" && field?.endOfDay === true && field?.dateTimeType === "date";
|
|
3097
3126
|
var isEndOfMonth = (field) => isPrimitive(field) && field.type === "DateTime" && field?.endOfMonth === true && field?.dateTimeType === "year_and_month";
|
|
3098
|
-
var doUpdate = async (model,
|
|
3127
|
+
var doUpdate = async (model, currentEntity, update, ctx) => {
|
|
3099
3128
|
if (model.updatable) {
|
|
3100
|
-
if (!
|
|
3101
|
-
|
|
3129
|
+
if (!update.updatedAt) {
|
|
3130
|
+
update.updatedAt = ctx.now;
|
|
3102
3131
|
}
|
|
3103
|
-
if (!
|
|
3104
|
-
|
|
3132
|
+
if (!update.updatedById) {
|
|
3133
|
+
update.updatedById = ctx.user?.id;
|
|
3105
3134
|
}
|
|
3106
3135
|
}
|
|
3107
3136
|
if (model.parent) {
|
|
@@ -3109,24 +3138,24 @@ var doUpdate = async (model, updateFields, allFields, ctx) => {
|
|
|
3109
3138
|
const childInput = {};
|
|
3110
3139
|
for (const field of model.fields) {
|
|
3111
3140
|
const columnName = field.kind === "relation" ? `${field.name}Id` : field.name;
|
|
3112
|
-
if (columnName in
|
|
3141
|
+
if (columnName in update) {
|
|
3113
3142
|
if (field.inherited) {
|
|
3114
|
-
rootInput[columnName] =
|
|
3143
|
+
rootInput[columnName] = update[columnName];
|
|
3115
3144
|
} else {
|
|
3116
|
-
childInput[columnName] =
|
|
3145
|
+
childInput[columnName] = update[columnName];
|
|
3117
3146
|
}
|
|
3118
3147
|
}
|
|
3119
3148
|
}
|
|
3120
3149
|
if (Object.keys(rootInput).length) {
|
|
3121
|
-
await ctx.knex(model.parent).where({ id:
|
|
3150
|
+
await ctx.knex(model.parent).where({ id: currentEntity.id }).update(rootInput);
|
|
3122
3151
|
}
|
|
3123
3152
|
if (Object.keys(childInput).length) {
|
|
3124
|
-
await ctx.knex(model.name).where({ id:
|
|
3153
|
+
await ctx.knex(model.name).where({ id: currentEntity.id }).update(childInput);
|
|
3125
3154
|
}
|
|
3126
3155
|
} else {
|
|
3127
|
-
await ctx.knex(model.name).where({ id:
|
|
3156
|
+
await ctx.knex(model.name).where({ id: currentEntity.id }).update(update);
|
|
3128
3157
|
}
|
|
3129
|
-
await createRevision(model,
|
|
3158
|
+
await createRevision(model, { ...currentEntity, ...update }, ctx);
|
|
3130
3159
|
};
|
|
3131
3160
|
|
|
3132
3161
|
// src/resolvers/resolvers.ts
|
|
@@ -3734,6 +3763,7 @@ var printSchemaFromModels = (models) => printSchema((0, import_graphql6.buildAST
|
|
|
3734
3763
|
queryRelations,
|
|
3735
3764
|
queryResolver,
|
|
3736
3765
|
resolve,
|
|
3766
|
+
restoreEntity,
|
|
3737
3767
|
retry,
|
|
3738
3768
|
scalar,
|
|
3739
3769
|
summon,
|
|
@@ -2,11 +2,12 @@ import { AnyDateType, Context } from '..';
|
|
|
2
2
|
import { EntityModel } from './models';
|
|
3
3
|
export type Entity = Record<string, unknown>;
|
|
4
4
|
export type Action = 'create' | 'update' | 'delete' | 'restore';
|
|
5
|
+
export type Trigger = 'mutation' | 'direct-call' | 'cascade' | 'set-null';
|
|
5
6
|
export type MutationContext<DateType extends AnyDateType = AnyDateType> = Pick<Context<DateType>, 'knex' | 'now' | 'user' | 'timeZone' | 'mutationHook' | 'handleUploads' | 'models' | 'permissions'>;
|
|
6
7
|
export type MutationHook<DateType extends AnyDateType = AnyDateType> = (args: {
|
|
7
8
|
model: EntityModel;
|
|
8
9
|
action: Action;
|
|
9
|
-
trigger:
|
|
10
|
+
trigger: Trigger;
|
|
10
11
|
when: 'before' | 'after';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IACrF,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;YACjB,OAAO,MAAM,EAAE,EAAE,CAAC;QACpB,CAAC;QACD,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC,CAAC;AAaF,MAAM,CAAC,MAAM,EAAE,GAAG,CAAyB,KAAc,EAAE,IAAO,EAAa,EAAE;IAC/E,IAAI,OAAO,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,KAAkB,CAAC;AAC5B,CAAC,CAAC"}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { GraphQLResolveInfo } from 'graphql';
|
|
2
2
|
import { Context } from '../context';
|
|
3
3
|
import { EntityModel } from '../models/models';
|
|
4
|
-
import { Entity, MutationContext } from '../models/mutation-hook';
|
|
5
|
-
export declare const mutationResolver: (_parent: any, args: any, partialCtx: Context, info: GraphQLResolveInfo) => Promise<
|
|
6
|
-
export declare const createEntity: (
|
|
7
|
-
export declare const updateEntities: (
|
|
8
|
-
export declare const updateEntity: (
|
|
9
|
-
export declare const deleteEntities: (
|
|
10
|
-
export declare const deleteEntity: (
|
|
4
|
+
import { Entity, MutationContext, Trigger } from '../models/mutation-hook';
|
|
5
|
+
export declare const mutationResolver: (_parent: any, args: any, partialCtx: Context, info: GraphQLResolveInfo) => Promise<any>;
|
|
6
|
+
export declare const createEntity: (modelName: string, input: Entity, ctx: MutationContext, trigger?: Trigger) => Promise<string>;
|
|
7
|
+
export declare const updateEntities: (modelName: string, where: Record<string, unknown>, updateFields: Entity, ctx: MutationContext) => Promise<void>;
|
|
8
|
+
export declare const updateEntity: (modelName: string, id: string, input: Entity, ctx: MutationContext, trigger?: Trigger) => Promise<void>;
|
|
9
|
+
export declare const deleteEntities: (modelName: string, where: Record<string, unknown>, deleteRootType: string | undefined, deleteRootId: string | undefined, ctx: MutationContext) => Promise<void>;
|
|
10
|
+
export declare const deleteEntity: (modelName: string, id: string, dryRun: boolean, deleteRootType: string | undefined, deleteRootId: string | undefined, ctx: MutationContext, trigger?: Trigger) => Promise<void>;
|
|
11
|
+
export declare const restoreEntity: (modelName: string, id: string, ctx: MutationContext, trigger?: Trigger) => Promise<void>;
|
|
11
12
|
export declare const createRevision: (model: EntityModel, data: Entity, ctx: MutationContext) => Promise<void>;
|