diff options
Diffstat (limited to 'app/assets/javascripts/work_items/graphql/resolvers.js')
-rw-r--r-- | app/assets/javascripts/work_items/graphql/resolvers.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/app/assets/javascripts/work_items/graphql/resolvers.js b/app/assets/javascripts/work_items/graphql/resolvers.js index e69de29bb2d..63d5234d083 100644 --- a/app/assets/javascripts/work_items/graphql/resolvers.js +++ b/app/assets/javascripts/work_items/graphql/resolvers.js @@ -0,0 +1,58 @@ +import { uuids } from '~/lib/utils/uuids'; +import workItemQuery from './work_item.query.graphql'; + +export const resolvers = { + Mutation: { + localCreateWorkItem(_, { input }, { cache }) { + const id = uuids()[0]; + const workItem = { + __typename: 'LocalWorkItem', + type: 'FEATURE', + id, + widgets: { + __typename: 'LocalWorkItemWidgetConnection', + nodes: [ + { + __typename: 'LocalTitleWidget', + type: 'TITLE', + enabled: true, + contentText: input.title, + }, + ], + }, + }; + + cache.writeQuery({ query: workItemQuery, variables: { id }, data: { workItem } }); + + return { + __typename: 'LocalCreateWorkItemPayload', + workItem, + }; + }, + + localUpdateWorkItem(_, { input }, { cache }) { + const workItemTitle = { + __typename: 'LocalTitleWidget', + type: 'TITLE', + enabled: true, + contentText: input.title, + }; + const workItem = { + __typename: 'LocalWorkItem', + type: 'FEATURE', + id: input.id, + widgets: { + __typename: 'LocalWorkItemWidgetConnection', + nodes: [workItemTitle], + }, + }; + + cache.writeQuery({ query: workItemQuery, variables: { id: input.id }, data: { workItem } }); + + return { + __typename: 'LocalUpdateWorkItemPayload', + workItem, + }; + }, + }, +}; |