feat: Implement draft version of Step model
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
a3dd76df21
commit
c48c905805
43
packages/backend/src/graphql/mutations/create-step.ts
Normal file
43
packages/backend/src/graphql/mutations/create-step.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { GraphQLString, GraphQLNonNull, GraphQLInt, GraphQLEnumType } from 'graphql';
|
||||
import Step from '../../models/step';
|
||||
import stepType from '../types/step';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
key: string,
|
||||
appKey: string,
|
||||
type: string
|
||||
connectionId: number
|
||||
}
|
||||
|
||||
const createStepResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
const step = await Step.query().insertAndFetch({
|
||||
key: params.key,
|
||||
appKey: params.appKey,
|
||||
type: params.type,
|
||||
connectionId: params.connectionId,
|
||||
});
|
||||
|
||||
return step;
|
||||
}
|
||||
|
||||
const createStep = {
|
||||
type: stepType,
|
||||
args: {
|
||||
key: { type: GraphQLNonNull(GraphQLString) },
|
||||
appKey: { type: GraphQLNonNull(GraphQLString) },
|
||||
type: {
|
||||
type: new GraphQLEnumType({
|
||||
name: 'StepInputEnumType',
|
||||
values: {
|
||||
trigger: { value: 'trigger' },
|
||||
action: { value: 'action' },
|
||||
}
|
||||
})
|
||||
},
|
||||
connectionId: { type: GraphQLNonNull(GraphQLInt) }
|
||||
},
|
||||
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => createStepResolver(params, req)
|
||||
};
|
||||
|
||||
export default createStep;
|
@@ -5,6 +5,7 @@ import updateConnection from './mutations/update-connection';
|
||||
import resetConnection from './mutations/reset-connection';
|
||||
import verifyConnection from './mutations/verify-connection';
|
||||
import deleteConnection from './mutations/delete-connection';
|
||||
import createStep from './mutations/create-step';
|
||||
|
||||
const rootMutation = new GraphQLObjectType({
|
||||
name: 'Mutation',
|
||||
@@ -14,7 +15,8 @@ const rootMutation = new GraphQLObjectType({
|
||||
updateConnection,
|
||||
resetConnection,
|
||||
verifyConnection,
|
||||
deleteConnection
|
||||
deleteConnection,
|
||||
createStep,
|
||||
}
|
||||
});
|
||||
|
||||
|
21
packages/backend/src/graphql/types/step.ts
Normal file
21
packages/backend/src/graphql/types/step.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { GraphQLObjectType, GraphQLString, GraphQLNonNull, GraphQLEnumType, GraphQLInt } from 'graphql';
|
||||
|
||||
const stepType = new GraphQLObjectType({
|
||||
name: 'Step',
|
||||
fields: {
|
||||
key: { type: GraphQLNonNull(GraphQLString) },
|
||||
appKey: { type: GraphQLNonNull(GraphQLString) },
|
||||
type: {
|
||||
type: new GraphQLEnumType({
|
||||
name: 'StepEnumType',
|
||||
values: {
|
||||
trigger: { value: 'trigger' },
|
||||
action: { value: 'action' },
|
||||
}
|
||||
})
|
||||
},
|
||||
connectionId: { type: GraphQLNonNull(GraphQLInt) }
|
||||
}
|
||||
})
|
||||
|
||||
export default stepType;
|
Reference in New Issue
Block a user