diff --git a/packages/backend/src/graphql/mutations/update-flow.ts b/packages/backend/src/graphql/mutations/update-flow.ts new file mode 100644 index 00000000..e22a1618 --- /dev/null +++ b/packages/backend/src/graphql/mutations/update-flow.ts @@ -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; diff --git a/packages/backend/src/graphql/root-mutation.ts b/packages/backend/src/graphql/root-mutation.ts index 28ea87c3..270722cd 100644 --- a/packages/backend/src/graphql/root-mutation.ts +++ b/packages/backend/src/graphql/root-mutation.ts @@ -6,6 +6,7 @@ import resetConnection from './mutations/reset-connection'; import verifyConnection from './mutations/verify-connection'; import deleteConnection from './mutations/delete-connection'; import createFlow from './mutations/create-flow'; +import updateFlow from './mutations/update-flow'; import createStep from './mutations/create-step'; import executeStep from './mutations/execute-step'; @@ -19,6 +20,7 @@ const rootMutation = new GraphQLObjectType({ verifyConnection, deleteConnection, createFlow, + updateFlow, createStep, executeStep } diff --git a/packages/web/src/components/AppFlowRow/index.tsx b/packages/web/src/components/AppFlowRow/index.tsx index 499507b3..435e4343 100644 --- a/packages/web/src/components/AppFlowRow/index.tsx +++ b/packages/web/src/components/AppFlowRow/index.tsx @@ -21,7 +21,7 @@ function AppFlowRow(props: AppFlowRowProps) { - + {flow.name} diff --git a/packages/web/src/components/AppFlowRow/style.ts b/packages/web/src/components/AppFlowRow/style.ts index e3dbd30d..6953d69b 100644 --- a/packages/web/src/components/AppFlowRow/style.ts +++ b/packages/web/src/components/AppFlowRow/style.ts @@ -12,6 +12,7 @@ export const CardContent = styled(MuiCardContent)(({ theme }) => ({ export const Typography = styled(MuiTypography)(({ theme }) => ({ - textAlign: 'center', display: 'inline-block', + width: 300, + maxWidth: '50%', })); diff --git a/packages/web/src/graphql/queries/get-app.ts b/packages/web/src/graphql/queries/get-app.ts index 694315db..2fa265a8 100644 --- a/packages/web/src/graphql/queries/get-app.ts +++ b/packages/web/src/graphql/queries/get-app.ts @@ -8,6 +8,7 @@ export const GET_APP = gql` iconUrl docUrl primaryColor + connectionCount fields { key label @@ -48,6 +49,11 @@ export const GET_APP = gql` connections { id } + triggers { + name + key + description + } } } `;