feat: make step in editor configurable
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
4985fb422e
commit
95a63affe7
@@ -1,34 +1,41 @@
|
||||
import { GraphQLInt, GraphQLString, GraphQLNonNull } from 'graphql';
|
||||
import Flow from '../../models/flow';
|
||||
import Step from '../../models/step';
|
||||
import stepType from '../types/step';
|
||||
import stepType, { stepInputType } from '../types/step';
|
||||
import availableAppsEnumType from '../types/available-apps-enum-type';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
id: number,
|
||||
flowId: number,
|
||||
key: string,
|
||||
appKey: string,
|
||||
connectionId: number
|
||||
input: {
|
||||
id: number,
|
||||
key: string,
|
||||
appKey: string,
|
||||
flow: {
|
||||
id: number,
|
||||
},
|
||||
connection: {
|
||||
id: number
|
||||
},
|
||||
}
|
||||
}
|
||||
const updateStepResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
const { input } = params;
|
||||
|
||||
const flow = await Flow.query().findOne({
|
||||
user_id: req.currentUser.id,
|
||||
id: params.flowId
|
||||
id: input.flow.id
|
||||
}).throwIfNotFound();
|
||||
|
||||
let step = await Step.query().findOne({
|
||||
flow_id: flow.id,
|
||||
id: params.id
|
||||
id: input.id
|
||||
}).throwIfNotFound();
|
||||
|
||||
step = await step.$query().patchAndFetch({
|
||||
...step,
|
||||
key: params.key,
|
||||
appKey: params.appKey,
|
||||
connectionId: params.connectionId
|
||||
})
|
||||
step = await Step.query().patchAndFetchById(input.id, {
|
||||
key: input.key,
|
||||
appKey: input.appKey,
|
||||
connectionId: input.connection.id,
|
||||
});
|
||||
|
||||
return step;
|
||||
}
|
||||
@@ -36,10 +43,7 @@ const updateStepResolver = async (params: Params, req: RequestWithCurrentUser) =
|
||||
const updateStep = {
|
||||
type: stepType,
|
||||
args: {
|
||||
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||
flowId: { type: GraphQLNonNull(GraphQLInt) },
|
||||
key: { type: GraphQLString },
|
||||
appKey: { type: availableAppsEnumType },
|
||||
input: { type: new GraphQLNonNull(stepInputType) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => updateStepResolver(params, req)
|
||||
};
|
||||
|
Reference in New Issue
Block a user