From 4bbdf66ade8994d2e04ea8f27ead434249096f6d Mon Sep 17 00:00:00 2001 From: getlarge Date: Wed, 13 May 2020 09:59:49 +0200 Subject: [PATCH] add preProcessor / postProcessor args types --- src/engine/action/Action.ts | 20 ++++++++++++++++++-- src/engine/entity/Entity.ts | 18 ++++++++++++++++-- src/engine/mutation/Mutation.ts | 26 ++++++++++++++++++++++++-- 3 files changed, 58 insertions(+), 6 deletions(-) diff --git a/src/engine/action/Action.ts b/src/engine/action/Action.ts index 7a49dd89..f9c6d081 100644 --- a/src/engine/action/Action.ts +++ b/src/engine/action/Action.ts @@ -23,8 +23,24 @@ export type ActionSetup = { resolve?: Function; type?: string; permissions?: Function | Permission | Permission[]; - preProcessor?: Function; - postProcessor?: Function; + // preProcessor?: Function; + // postProcessor?: Function; + preProcessor?: ( + action?: Action, + source?: any, + payload?: any, + context?: any, + info?: any, + ) => Promise | void; + postProcessor?: ( + error?: any, + result?: any, + action?: Action, + source?: any, + payload?: any, + context?: any, + info?: any, + ) => Promise | void; }; export class Action { diff --git a/src/engine/entity/Entity.ts b/src/engine/entity/Entity.ts index 8c52712c..f0ec201e 100644 --- a/src/engine/entity/Entity.ts +++ b/src/engine/entity/Entity.ts @@ -74,8 +74,22 @@ export type EntitySetup = { permissions?: any; subscriptions?: any; states?: any; - preProcessor?: Function; - postProcessor?: Function; + // preProcessor?: Function; + // postProcessor?: Function; + preProcessor?: ( + entity?: Entity, + args?: any, + context?: any, + info?: any, + ) => Promise | any; + postProcessor?: ( + translatedRow?: any, + entity?: Entity, + source?: any, + args?: any, + context?: any, + info?: any, + ) => Promise | any; preFilters?: PreFilterType; preFiltersGenerator?: PreFilterGeneratorType; meta?: any; diff --git a/src/engine/mutation/Mutation.ts b/src/engine/mutation/Mutation.ts index 875f6070..3b1ec070 100644 --- a/src/engine/mutation/Mutation.ts +++ b/src/engine/mutation/Mutation.ts @@ -40,8 +40,30 @@ export type MutationSetup = { type?: string; description?: string; attributes?: string[]; - preProcessor?: Function; - postProcessor?: Function; + // preProcessor?: Function; + // postProcessor?: Function; + preProcessor?: ( + entity?: Entity, + id?: string | number, + source?: any, + input?: any, + typeName?: string, + entityMutation?: Mutation, + context?: any, + info?: any, + ) => Promise | any; + postProcessor?: ( + error?: any, + result?: any, + entity?: Entity, + id?: string | number, + source?: any, + input?: any, + typeName?: string, + entityMutation?: Mutation, + context?: any, + info?: any, + ) => Promise | void; fromState?: string | string[]; toState?: string | string[]; };