feat: add updateFlow mutation
This commit is contained in:
33
packages/backend/src/graphql/mutations/update-flow.ts
Normal file
33
packages/backend/src/graphql/mutations/update-flow.ts
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { GraphQLInt, GraphQLString, GraphQLNonNull } from 'graphql';
|
||||||
|
import Flow from '../../models/flow';
|
||||||
|
import flowType from '../types/flow';
|
||||||
|
import RequestWithCurrentUser from '../../types/express/request-with-current-user';
|
||||||
|
|
||||||
|
type Params = {
|
||||||
|
id: string,
|
||||||
|
data: object
|
||||||
|
}
|
||||||
|
const updateFlowResolver = async (params: Params, req: RequestWithCurrentUser) => {
|
||||||
|
let flow = await Flow.query().findOne({
|
||||||
|
user_id: req.currentUser.id,
|
||||||
|
id: params.id
|
||||||
|
}).throwIfNotFound();
|
||||||
|
|
||||||
|
flow = await flow.$query().patchAndFetch({
|
||||||
|
...flow,
|
||||||
|
...params
|
||||||
|
})
|
||||||
|
|
||||||
|
return flow;
|
||||||
|
}
|
||||||
|
|
||||||
|
const updateFlow = {
|
||||||
|
type: flowType,
|
||||||
|
args: {
|
||||||
|
id: { type: GraphQLNonNull(GraphQLInt) },
|
||||||
|
name: { type: GraphQLNonNull(GraphQLString) }
|
||||||
|
},
|
||||||
|
resolve: (_: any, params: Params, req: RequestWithCurrentUser) => updateFlowResolver(params, req)
|
||||||
|
};
|
||||||
|
|
||||||
|
export default updateFlow;
|
@@ -6,6 +6,7 @@ import resetConnection from './mutations/reset-connection';
|
|||||||
import verifyConnection from './mutations/verify-connection';
|
import verifyConnection from './mutations/verify-connection';
|
||||||
import deleteConnection from './mutations/delete-connection';
|
import deleteConnection from './mutations/delete-connection';
|
||||||
import createFlow from './mutations/create-flow';
|
import createFlow from './mutations/create-flow';
|
||||||
|
import updateFlow from './mutations/update-flow';
|
||||||
import createStep from './mutations/create-step';
|
import createStep from './mutations/create-step';
|
||||||
import executeStep from './mutations/execute-step';
|
import executeStep from './mutations/execute-step';
|
||||||
|
|
||||||
@@ -19,6 +20,7 @@ const rootMutation = new GraphQLObjectType({
|
|||||||
verifyConnection,
|
verifyConnection,
|
||||||
deleteConnection,
|
deleteConnection,
|
||||||
createFlow,
|
createFlow,
|
||||||
|
updateFlow,
|
||||||
createStep,
|
createStep,
|
||||||
executeStep
|
executeStep
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,7 @@ function AppFlowRow(props: AppFlowRowProps) {
|
|||||||
<CardActionArea component={Link} to={URLS.FLOW('dummy')}>
|
<CardActionArea component={Link} to={URLS.FLOW('dummy')}>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Box>
|
<Box>
|
||||||
<Typography variant="h6">
|
<Typography variant="h6" noWrap>
|
||||||
{flow.name}
|
{flow.name}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
|
@@ -12,6 +12,7 @@ export const CardContent = styled(MuiCardContent)(({ theme }) => ({
|
|||||||
|
|
||||||
|
|
||||||
export const Typography = styled(MuiTypography)(({ theme }) => ({
|
export const Typography = styled(MuiTypography)(({ theme }) => ({
|
||||||
textAlign: 'center',
|
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
|
width: 300,
|
||||||
|
maxWidth: '50%',
|
||||||
}));
|
}));
|
||||||
|
@@ -8,6 +8,7 @@ export const GET_APP = gql`
|
|||||||
iconUrl
|
iconUrl
|
||||||
docUrl
|
docUrl
|
||||||
primaryColor
|
primaryColor
|
||||||
|
connectionCount
|
||||||
fields {
|
fields {
|
||||||
key
|
key
|
||||||
label
|
label
|
||||||
@@ -48,6 +49,11 @@ export const GET_APP = gql`
|
|||||||
connections {
|
connections {
|
||||||
id
|
id
|
||||||
}
|
}
|
||||||
|
triggers {
|
||||||
|
name
|
||||||
|
key
|
||||||
|
description
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
Reference in New Issue
Block a user