Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(EMI-2026): Add homeViewTasksSection to success response when clearing a task. #6343

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions _schemaV2.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type AckTaskMutationPayload {
union AckTaskResponseOrError = AckTaskFailure | AckTaskSuccess

type AckTaskSuccess {
homeViewTasksSection: HomeViewSectionTasks
task: Task!
}

Expand Down Expand Up @@ -9384,6 +9385,7 @@ type DismissTaskMutationPayload {
union DismissTaskResponseOrError = DismissTaskFailure | DismissTaskSuccess

type DismissTaskSuccess {
homeViewTasksSection: HomeViewSectionTasks
task: Task!
}

Expand Down
11 changes: 3 additions & 8 deletions src/schema/v2/homeView/sectionTypes/Tasks.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { GraphQLObjectType } from "graphql"
import { pageable } from "relay-cursor-paging"
import {
connectionWithCursorInfo,
emptyConnection,
} from "schema/v2/fields/pagination"
import { TaskType } from "schema/v2/me/task"
import { emptyConnection } from "schema/v2/fields/pagination"
import { TaskConnectionType } from "schema/v2/me/task"
import { NodeInterface } from "schema/v2/object_identification"
import { ResolverContext } from "types/graphql"
import {
Expand All @@ -24,9 +21,7 @@ export const HomeViewTasksSectionType = new GraphQLObjectType<
...standardSectionFields,

tasksConnection: {
type: connectionWithCursorInfo({
nodeType: TaskType,
}).connectionType,
type: TaskConnectionType,
args: pageable({}),
resolve: (parent, ...rest) =>
parent.resolver ? parent.resolver(parent, ...rest) : emptyConnection,
Expand Down
21 changes: 21 additions & 0 deletions src/schema/v2/me/__tests__/ack_task_mutation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ describe("AckTaskMutation", () => {
internalID
title
}
homeViewTasksSection {
tasksConnection(first: 10) {
edges {
node {
internalID
title
}
}
}
}
}
... on AckTaskFailure {
mutationError {
Expand All @@ -30,6 +40,13 @@ describe("AckTaskMutation", () => {
internalID: "task-id",
title: "Test Task",
},
homeViewTasksSection: {
tasksConnection: {
edges: [
{ node: { internalID: "asdf1234", title: "Remaining Task" } },
],
},
},
},
},
}
Expand All @@ -39,6 +56,10 @@ describe("AckTaskMutation", () => {
id: "task-id",
title: "Test Task",
}),
meTasksLoader: jest.fn().mockResolvedValue({
body: [{ id: "asdf1234", title: "Remaining Task" }],
headers: { "x-total-count": 1 },
}),
}

const data = await runAuthenticatedQuery(mutation, context)
Expand Down
21 changes: 21 additions & 0 deletions src/schema/v2/me/__tests__/dismiss_task_mutation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ describe("DismissTaskMutation", () => {
internalID
title
}
homeViewTasksSection {
tasksConnection(first: 10) {
edges {
node {
internalID
title
}
}
}
}
}
... on DismissTaskFailure {
mutationError {
Expand All @@ -30,6 +40,13 @@ describe("DismissTaskMutation", () => {
internalID: "task-id",
title: "Test Task",
},
homeViewTasksSection: {
tasksConnection: {
edges: [
{ node: { internalID: "asdf1234", title: "Remaining Task" } },
],
},
},
},
},
}
Expand All @@ -39,6 +56,10 @@ describe("DismissTaskMutation", () => {
id: "task-id",
title: "Test Task",
}),
meTasksLoader: jest.fn().mockResolvedValue({
body: [{ id: "asdf1234", title: "Remaining Task" }],
headers: { "x-total-count": 1 },
}),
}

const data = await runAuthenticatedQuery(mutation, context)
Expand Down
6 changes: 6 additions & 0 deletions src/schema/v2/me/ack_task_mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from "lib/gravityErrorHandler"
import { ResolverContext } from "types/graphql"
import { Task, TaskType } from "./task"
import { HomeViewTasksSectionType } from "../homeView/sectionTypes/Tasks"
import { Tasks } from "../homeView/sections/Tasks"

interface Input {
id: string
Expand All @@ -26,6 +28,10 @@ const SuccessType = new GraphQLObjectType<any, ResolverContext>({
return response
},
},
homeViewTasksSection: {
type: HomeViewTasksSectionType,
resolve: () => Tasks,
},
}),
})

Expand Down
8 changes: 7 additions & 1 deletion src/schema/v2/me/dismiss_task_mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
} from "lib/gravityErrorHandler"
import { ResolverContext } from "types/graphql"
import { Task, TaskType } from "./task"
import { HomeViewTasksSectionType } from "../homeView/sectionTypes/Tasks"
import { Tasks } from "../homeView/sections/Tasks"

interface Input {
id: string
Expand All @@ -26,6 +28,10 @@ const SuccessType = new GraphQLObjectType<any, ResolverContext>({
return response
},
},
homeViewTasksSection: {
type: HomeViewTasksSectionType,
resolve: () => Tasks,
},
}),
})

Expand Down Expand Up @@ -74,7 +80,7 @@ export const dismissTaskMutation = mutationWithClientMutationId<
try {
const task: Task = await meDismissTaskLoader?.(id)

return { ...task, __typename: "SuccessType" }
return { ...task, _type: "SuccessType" }
} catch (error) {
const formattedErr = formatGravityError(error)

Expand Down
5 changes: 5 additions & 0 deletions src/schema/v2/me/task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GraphQLNonNull, GraphQLObjectType, GraphQLString } from "graphql"
import { ResolverContext } from "types/graphql"
import { IDFields, NodeInterface } from "../object_identification"
import { date } from "./../fields/date"
import { connectionWithCursorInfo } from "../fields/pagination"

export interface Task {
image_url: string
Expand Down Expand Up @@ -47,3 +48,7 @@ export const TaskType = new GraphQLObjectType<any, ResolverContext>({
createdAt: date(),
}),
})

export const TaskConnectionType = connectionWithCursorInfo({
nodeType: TaskType,
}).connectionType