chore: Adjust create step mutation to work with flows
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
8a7d54bb25
commit
f8e823545a
@@ -1,9 +1,11 @@
|
||||
import { GraphQLString, GraphQLNonNull, GraphQLInt, GraphQLEnumType } from 'graphql';
|
||||
import Step from '../../models/step';
|
||||
import Flow from '../../models/flow';
|
||||
import stepType from '../types/step';
|
||||
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||
|
||||
type Params = {
|
||||
flowId: number,
|
||||
key: string,
|
||||
appKey: string,
|
||||
type: string
|
||||
@@ -11,7 +13,13 @@ type Params = {
|
||||
}
|
||||
|
||||
const createStepResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||
const flow = await Flow.query().findOne({
|
||||
id: params.flowId,
|
||||
user_id: req.currentUser.id
|
||||
})
|
||||
|
||||
const step = await Step.query().insertAndFetch({
|
||||
flowId: flow.id,
|
||||
key: params.key,
|
||||
appKey: params.appKey,
|
||||
type: params.type,
|
||||
@@ -24,6 +32,7 @@ const createStepResolver = async (params: Params, req: RequestWithCurrentUser) =
|
||||
const createStep = {
|
||||
type: stepType,
|
||||
args: {
|
||||
flowId: { type: GraphQLNonNull(GraphQLString) },
|
||||
key: { type: GraphQLNonNull(GraphQLString) },
|
||||
appKey: { type: GraphQLNonNull(GraphQLString) },
|
||||
type: {
|
||||
|
@@ -3,6 +3,7 @@ import { GraphQLObjectType, GraphQLString } from 'graphql';
|
||||
const flowType = new GraphQLObjectType({
|
||||
name: 'Flow',
|
||||
fields: {
|
||||
id: { type: GraphQLString },
|
||||
name: { type: GraphQLString }
|
||||
}
|
||||
})
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import Base from './base'
|
||||
import Flow from './flow'
|
||||
import Base from './base';
|
||||
import Flow from './flow';
|
||||
|
||||
enum StepEnumType {
|
||||
'trigger',
|
||||
@@ -8,6 +8,7 @@ enum StepEnumType {
|
||||
|
||||
class Step extends Base {
|
||||
id!: number
|
||||
flowId!: number
|
||||
key!: string
|
||||
appKey!: string
|
||||
type!: StepEnumType
|
||||
@@ -22,6 +23,7 @@ class Step extends Base {
|
||||
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
flowId: { type: 'integer' },
|
||||
key: { type: 'string', minLength: 1, maxLength: 255 },
|
||||
appKey: { type: 'string', minLength: 1, maxLength: 255 },
|
||||
type: { type: "string", enum: ["action", "trigger"] },
|
||||
|
Reference in New Issue
Block a user