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'
mutation createWorkItem($input: CreateWorkItemInput) {
createWorkItem(input: $input) @client {
mutation createWorkItem($input: LocalCreateWorkItemInput) {
localCreateWorkItem(input: $input) @client {
workItem {
id
type
widgets {
nodes {
...WidgetBase
... on TitleWidget {
... on LocalTitleWidget {
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() {
},
data: {
workItem: {
__typename: 'WorkItem',
__typename: 'LocalWorkItem',
id: '1',
type: 'FEATURE',
widgets: {
__typename: 'WorkItemWidgetConnection',
__typename: 'LocalWorkItemWidgetConnection',
nodes: [
{
__typename: 'TitleWidget',
__typename: 'LocalTitleWidget',
type: 'TITLE',
enabled: true,
// eslint-disable-next-line @gitlab/require-i18n-strings
......
......@@ -3,17 +3,17 @@ import workItemQuery from './work_item.query.graphql';
export const resolvers = {
Mutation: {
createWorkItem(_, { input }, { cache }) {
localCreateWorkItem(_, { input }, { cache }) {
const id = uuids()[0];
const workItem = {
__typename: 'WorkItem',
__typename: 'LocalWorkItem',
type: 'FEATURE',
id,
widgets: {
__typename: 'WorkItemWidgetConnection',
__typename: 'LocalWorkItemWidgetConnection',
nodes: [
{
__typename: 'TitleWidget',
__typename: 'LocalTitleWidget',
type: 'TITLE',
enabled: true,
contentText: input.title,
......@@ -25,24 +25,24 @@ export const resolvers = {
cache.writeQuery({ query: workItemQuery, variables: { id }, data: { workItem } });
return {
__typename: 'CreateWorkItemPayload',
__typename: 'LocalCreateWorkItemPayload',
workItem,
};
},
updateWorkItem(_, { input }, { cache }) {
localUpdateWorkItem(_, { input }, { cache }) {
const workItemTitle = {
__typename: 'TitleWidget',
__typename: 'LocalTitleWidget',
type: 'TITLE',
enabled: true,
contentText: input.title,
};
const workItem = {
__typename: 'WorkItem',
__typename: 'LocalWorkItem',
type: 'FEATURE',
id: input.id,
widgets: {
__typename: 'WorkItemWidgetConnection',
__typename: 'LocalWorkItemWidgetConnection',
nodes: [workItemTitle],
},
};
......@@ -50,7 +50,7 @@ export const resolvers = {
cache.writeQuery({ query: workItemQuery, variables: { id: input.id }, data: { workItem } });
return {
__typename: 'UpdateWorkItemPayload',
__typename: 'LocalUpdateWorkItemPayload',
workItem,
};
},
......
enum WorkItemType {
enum LocalWorkItemType {
FEATURE
}
enum WidgetType {
enum LocalWidgetType {
TITLE
}
interface WorkItemWidget {
type: WidgetType!
interface LocalWorkItemWidget {
type: LocalWidgetType!
}
# Replicating Relay connection type for client schema
type WorkItemWidgetEdge {
type LocalWorkItemWidgetEdge {
cursor: String!
node: WorkItemWidget
node: LocalWorkItemWidget
}
type WorkItemWidgetConnection {
edges: [WorkItemWidgetEdge]
nodes: [WorkItemWidget]
type LocalWorkItemWidgetConnection {
edges: [LocalWorkItemWidgetEdge]
nodes: [LocalWorkItemWidget]
pageInfo: PageInfo!
}
type TitleWidget implements WorkItemWidget {
type: WidgetType!
type LocalTitleWidget implements LocalWorkItemWidget {
type: LocalWidgetType!
contentText: String!
}
type WorkItem {
type LocalWorkItem {
id: ID!
type: WorkItemType!
widgets: [WorkItemWidgetConnection]
type: LocalWorkItemType!
widgets: [LocalWorkItemWidgetConnection]
}
type CreateWorkItemInput {
type LocalCreateWorkItemInput {
title: String!
}
type UpdateWorkItemInput {
type LocalUpdateWorkItemInput {
id: ID!
title: String
}
type CreateWorkItemPayload {
workItem: WorkItem!
type LocalCreateWorkItemPayload {
workItem: LocalWorkItem!
}
type UpdateWorkItemPayload {
workItem: WorkItem!
type LocalUpdateWorkItemPayload {
workItem: LocalWorkItem!
}
extend type Query {
workItem(id: ID!): WorkItem!
workItem(id: ID!): LocalWorkItem!
}
extend type Mutation {
createWorkItem(input: CreateWorkItemInput!): CreateWorkItemPayload!
updateWorkItem(input: UpdateWorkItemInput!): UpdateWorkItemPayload!
localCreateWorkItem(input: LocalCreateWorkItemInput!): LocalCreateWorkItemPayload!
localUpdateWorkItem(input: LocalUpdateWorkItemInput!): LocalUpdateWorkItemPayload!
}
#import './widget.fragment.graphql'
mutation updateWorkItem($input: UpdateWorkItemInput) {
updateWorkItem(input: $input) @client {
mutation updateWorkItem($input: LocalUpdateWorkItemInput) {
localUpdateWorkItem(input: $input) @client {
workItem {
id
type
widgets {
nodes {
...WidgetBase
... on TitleWidget {
... on LocalTitleWidget {
contentText
}
}
......
fragment WidgetBase on WorkItemWidget {
fragment WidgetBase on LocalWorkItemWidget {
type
}
......@@ -7,7 +7,7 @@ query WorkItem($id: ID!) {
widgets {
nodes {
...WidgetBase
... on TitleWidget {
... on LocalTitleWidget {
contentText
}
}
......
......@@ -30,7 +30,7 @@ export default {
const {
data: {
createWorkItem: {
localCreateWorkItem: {
workItem: { id },
},
},
......@@ -60,11 +60,10 @@ export default {
class="gl-mr-3"
data-testid="create-button"
type="submit"
@click="createWorkItem"
>
{{ __('Create') }}
</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') }}
</gl-button>
</div>
......
export const workItemQueryResponse = {
workItem: {
__typename: 'WorkItem',
__typename: 'LocalWorkItem',
id: '1',
type: 'FEATURE',
widgets: {
__typename: 'WorkItemWidgetConnection',
__typename: 'LocalWorkItemWidgetConnection',
nodes: [
{
__typename: 'TitleWidget',
__typename: 'LocalTitleWidget',
type: 'TITLE',
contentText: 'Test',
},
......@@ -17,15 +17,15 @@ export const workItemQueryResponse = {
};
export const updateWorkItemMutationResponse = {
__typename: 'UpdateWorkItemPayload',
__typename: 'LocalUpdateWorkItemPayload',
workItem: {
__typename: 'WorkItem',
__typename: 'LocalWorkItem',
id: '1',
widgets: {
__typename: 'WorkItemWidgetConnection',
__typename: 'LocalWorkItemWidgetConnection',
nodes: [
{
__typename: 'TitleWidget',
__typename: 'LocalTitleWidget',
type: 'TITLE',
enabled: true,
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