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: {
|
||||
|
Reference in New Issue
Block a user