Commit 640eb291 authored by Mario Celi's avatar Mario Celi Committed by Natalia Tepluhina

Renamed local GraphQL Work Item types

parent 1d211d12
#import './widget.fragment.graphql' #import './widget.fragment.graphql'
mutation createWorkItem($input: CreateWorkItemInput) { mutation createWorkItem($input: LocalCreateWorkItemInput) {
createWorkItem(input: $input) @client { localCreateWorkItem(input: $input) @client {
workItem { workItem {
id id
type type
widgets { widgets {
nodes { nodes {
...WidgetBase ...WidgetBase
... on TitleWidget { ... on LocalTitleWidget {
contentText contentText
} }
} }
......
{"__schema":{"types":[{"kind":"INTERFACE","name":"WorkItemWidget","possibleTypes":[{"name":"TitleWidget"}]}]}} {"__schema":{"types":[{"kind":"INTERFACE","name":"LocalWorkItemWidget","possibleTypes":[{"name":"LocalTitleWidget"}]}]}}
...@@ -28,14 +28,14 @@ export function createApolloProvider() { ...@@ -28,14 +28,14 @@ export function createApolloProvider() {
}, },
data: { data: {
workItem: { workItem: {
__typename: 'WorkItem', __typename: 'LocalWorkItem',
id: '1', id: '1',
type: 'FEATURE', type: 'FEATURE',
widgets: { widgets: {
__typename: 'WorkItemWidgetConnection', __typename: 'LocalWorkItemWidgetConnection',
nodes: [ nodes: [
{ {
__typename: 'TitleWidget', __typename: 'LocalTitleWidget',
type: 'TITLE', type: 'TITLE',
enabled: true, enabled: true,
// eslint-disable-next-line @gitlab/require-i18n-strings // eslint-disable-next-line @gitlab/require-i18n-strings
......
...@@ -3,17 +3,17 @@ import workItemQuery from './work_item.query.graphql'; ...@@ -3,17 +3,17 @@ import workItemQuery from './work_item.query.graphql';
export const resolvers = { export const resolvers = {
Mutation: { Mutation: {
createWorkItem(_, { input }, { cache }) { localCreateWorkItem(_, { input }, { cache }) {
const id = uuids()[0]; const id = uuids()[0];
const workItem = { const workItem = {
__typename: 'WorkItem', __typename: 'LocalWorkItem',
type: 'FEATURE', type: 'FEATURE',
id, id,
widgets: { widgets: {
__typename: 'WorkItemWidgetConnection', __typename: 'LocalWorkItemWidgetConnection',
nodes: [ nodes: [
{ {
__typename: 'TitleWidget', __typename: 'LocalTitleWidget',
type: 'TITLE', type: 'TITLE',
enabled: true, enabled: true,
contentText: input.title, contentText: input.title,
...@@ -25,24 +25,24 @@ export const resolvers = { ...@@ -25,24 +25,24 @@ export const resolvers = {
cache.writeQuery({ query: workItemQuery, variables: { id }, data: { workItem } }); cache.writeQuery({ query: workItemQuery, variables: { id }, data: { workItem } });
return { return {
__typename: 'CreateWorkItemPayload', __typename: 'LocalCreateWorkItemPayload',
workItem, workItem,
}; };
}, },
updateWorkItem(_, { input }, { cache }) { localUpdateWorkItem(_, { input }, { cache }) {
const workItemTitle = { const workItemTitle = {
__typename: 'TitleWidget', __typename: 'LocalTitleWidget',
type: 'TITLE', type: 'TITLE',
enabled: true, enabled: true,
contentText: input.title, contentText: input.title,
}; };
const workItem = { const workItem = {
__typename: 'WorkItem', __typename: 'LocalWorkItem',
type: 'FEATURE', type: 'FEATURE',
id: input.id, id: input.id,
widgets: { widgets: {
__typename: 'WorkItemWidgetConnection', __typename: 'LocalWorkItemWidgetConnection',
nodes: [workItemTitle], nodes: [workItemTitle],
}, },
}; };
...@@ -50,7 +50,7 @@ export const resolvers = { ...@@ -50,7 +50,7 @@ export const resolvers = {
cache.writeQuery({ query: workItemQuery, variables: { id: input.id }, data: { workItem } }); cache.writeQuery({ query: workItemQuery, variables: { id: input.id }, data: { workItem } });
return { return {
__typename: 'UpdateWorkItemPayload', __typename: 'LocalUpdateWorkItemPayload',
workItem, workItem,
}; };
}, },
......
enum WorkItemType { enum LocalWorkItemType {
FEATURE FEATURE
} }
enum WidgetType { enum LocalWidgetType {
TITLE TITLE
} }
interface WorkItemWidget { interface LocalWorkItemWidget {
type: WidgetType! type: LocalWidgetType!
} }
# Replicating Relay connection type for client schema # Replicating Relay connection type for client schema
type WorkItemWidgetEdge { type LocalWorkItemWidgetEdge {
cursor: String! cursor: String!
node: WorkItemWidget node: LocalWorkItemWidget
} }
type WorkItemWidgetConnection { type LocalWorkItemWidgetConnection {
edges: [WorkItemWidgetEdge] edges: [LocalWorkItemWidgetEdge]
nodes: [WorkItemWidget] nodes: [LocalWorkItemWidget]
pageInfo: PageInfo! pageInfo: PageInfo!
} }
type TitleWidget implements WorkItemWidget { type LocalTitleWidget implements LocalWorkItemWidget {
type: WidgetType! type: LocalWidgetType!
contentText: String! contentText: String!
} }
type WorkItem { type LocalWorkItem {
id: ID! id: ID!
type: WorkItemType! type: LocalWorkItemType!
widgets: [WorkItemWidgetConnection] widgets: [LocalWorkItemWidgetConnection]
} }
type CreateWorkItemInput { type LocalCreateWorkItemInput {
title: String! title: String!
} }
type UpdateWorkItemInput { type LocalUpdateWorkItemInput {
id: ID! id: ID!
title: String title: String
} }
type CreateWorkItemPayload { type LocalCreateWorkItemPayload {
workItem: WorkItem! workItem: LocalWorkItem!
} }
type UpdateWorkItemPayload { type LocalUpdateWorkItemPayload {
workItem: WorkItem! workItem: LocalWorkItem!
} }
extend type Query { extend type Query {
workItem(id: ID!): WorkItem! workItem(id: ID!): LocalWorkItem!
} }
extend type Mutation { extend type Mutation {
createWorkItem(input: CreateWorkItemInput!): CreateWorkItemPayload! localCreateWorkItem(input: LocalCreateWorkItemInput!): LocalCreateWorkItemPayload!
updateWorkItem(input: UpdateWorkItemInput!): UpdateWorkItemPayload! localUpdateWorkItem(input: LocalUpdateWorkItemInput!): LocalUpdateWorkItemPayload!
} }
#import './widget.fragment.graphql' #import './widget.fragment.graphql'
mutation updateWorkItem($input: UpdateWorkItemInput) { mutation updateWorkItem($input: LocalUpdateWorkItemInput) {
updateWorkItem(input: $input) @client { localUpdateWorkItem(input: $input) @client {
workItem { workItem {
id id
type type
widgets { widgets {
nodes { nodes {
...WidgetBase ...WidgetBase
... on TitleWidget { ... on LocalTitleWidget {
contentText contentText
} }
} }
......
fragment WidgetBase on WorkItemWidget { fragment WidgetBase on LocalWorkItemWidget {
type type
} }
...@@ -7,7 +7,7 @@ query WorkItem($id: ID!) { ...@@ -7,7 +7,7 @@ query WorkItem($id: ID!) {
widgets { widgets {
nodes { nodes {
...WidgetBase ...WidgetBase
... on TitleWidget { ... on LocalTitleWidget {
contentText contentText
} }
} }
......
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
const { const {
data: { data: {
createWorkItem: { localCreateWorkItem: {
workItem: { id }, workItem: { id },
}, },
}, },
...@@ -60,11 +60,10 @@ export default { ...@@ -60,11 +60,10 @@ export default {
class="gl-mr-3" class="gl-mr-3"
data-testid="create-button" data-testid="create-button"
type="submit" type="submit"
@click="createWorkItem"
> >
{{ __('Create') }} {{ __('Create') }}
</gl-button> </gl-button>
<gl-button data-testid="cancel-button" @click="$router.go(-1)"> <gl-button type="button" data-testid="cancel-button" @click="$router.go(-1)">
{{ __('Cancel') }} {{ __('Cancel') }}
</gl-button> </gl-button>
</div> </div>
......
export const workItemQueryResponse = { export const workItemQueryResponse = {
workItem: { workItem: {
__typename: 'WorkItem', __typename: 'LocalWorkItem',
id: '1', id: '1',
type: 'FEATURE', type: 'FEATURE',
widgets: { widgets: {
__typename: 'WorkItemWidgetConnection', __typename: 'LocalWorkItemWidgetConnection',
nodes: [ nodes: [
{ {
__typename: 'TitleWidget', __typename: 'LocalTitleWidget',
type: 'TITLE', type: 'TITLE',
contentText: 'Test', contentText: 'Test',
}, },
...@@ -17,15 +17,15 @@ export const workItemQueryResponse = { ...@@ -17,15 +17,15 @@ export const workItemQueryResponse = {
}; };
export const updateWorkItemMutationResponse = { export const updateWorkItemMutationResponse = {
__typename: 'UpdateWorkItemPayload', __typename: 'LocalUpdateWorkItemPayload',
workItem: { workItem: {
__typename: 'WorkItem', __typename: 'LocalWorkItem',
id: '1', id: '1',
widgets: { widgets: {
__typename: 'WorkItemWidgetConnection', __typename: 'LocalWorkItemWidgetConnection',
nodes: [ nodes: [
{ {
__typename: 'TitleWidget', __typename: 'LocalTitleWidget',
type: 'TITLE', type: 'TITLE',
enabled: true, enabled: true,
contentText: 'Updated title', contentText: 'Updated title',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment