Skip to content

Commit 32f1c10

Browse files
add types for mutations (codesandbox#3619)
1 parent 0cd9537 commit 32f1c10

File tree

3 files changed

+71
-6
lines changed

3 files changed

+71
-6
lines changed

packages/app/src/app/overmind/effects/fakeGql/comments/mutations.ts

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
import gql from 'graphql-tag';
22
import { Query } from 'overmind-graphql';
3+
import {
4+
AddCommentResponse,
5+
AddCommentVariables,
6+
DeleteCommentVariables,
7+
DeleteCommentResponse,
8+
UpdateCommentVariables,
9+
UpdateCommentResponse,
10+
} from './types';
311

4-
export const addComment: Query<any, any> = gql`
12+
export const addComment: Query<AddCommentResponse, AddCommentVariables> = gql`
513
mutation AddComment(
614
$sandboxId: String!
715
$comment: String!
816
$username: String!
17+
$metadata: String
918
) {
10-
addComment(sandboxId: $sandboxId, comment: $comment, username: $username) {
19+
addComment(
20+
sandboxId: $sandboxId
21+
comment: $comment
22+
username: $username
23+
metadata: $metadata
24+
) {
1125
id
1226
isResolved
1327
originalMessage {
@@ -22,25 +36,37 @@ export const addComment: Query<any, any> = gql`
2236
replies {
2337
id
2438
}
39+
metadata
2540
insertedAt
2641
updatedAt
2742
}
2843
}
2944
`;
3045

31-
export const deleteComment: Query<any, any> = gql`
46+
export const deleteComment: Query<
47+
DeleteCommentResponse,
48+
DeleteCommentVariables
49+
> = gql`
3250
mutation DeleteComment($id: String!) {
3351
deleteComment(id: $id) {
3452
id
3553
}
3654
}
3755
`;
3856

39-
export const updateComment: Query<any, any> = gql`
40-
mutation UpdateComment($id: String!, $comment: String, $isResolved: Boolean) {
57+
export const updateComment: Query<
58+
UpdateCommentResponse,
59+
UpdateCommentVariables
60+
> = gql`
61+
mutation UpdateComment(
62+
$id: String!
63+
$comment: String
64+
$isResolved: Boolean
65+
$metadata: String
66+
) {
4167
updateComment(
4268
id: $id
43-
data: { comment: $comment, isResolved: $isResolved }
69+
data: { comment: $comment, isResolved: $isResolved, metadata: $metadata }
4470
) {
4571
id
4672
isResolved

packages/app/src/app/overmind/effects/fakeGql/comments/queries.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const allComments: Query<CommentsResponse, CommentsVariables> = gql`
3232
}
3333
insertedAt
3434
updatedAt
35+
metadata
3536
}
3637
}
3738
`;
@@ -59,6 +60,7 @@ export const comment: Query<CommentResponse, CommentVariables> = gql`
5960
}
6061
insertedAt
6162
updatedAt
63+
metadata
6264
}
6365
}
6466
`;

packages/app/src/app/overmind/effects/fakeGql/comments/types.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export type Comment = {
1717
replies: Message[];
1818
insertedAt: string;
1919
updatedAt?: string;
20+
metadata?: string;
2021
};
2122

2223
export type CommentsVariables = {
@@ -32,6 +33,7 @@ export type CommentsResponse = {
3233
originalMessage: Message;
3334
insertedAt: string;
3435
updatedAt: string;
36+
metadata: string;
3537
}
3638
];
3739
};
@@ -40,12 +42,46 @@ export type AddCommentVariables = {
4042
sandboxId: string;
4143
comment: string;
4244
username: string;
45+
metadata?: string;
4346
};
4447

4548
export type AddCommentResponse = {
4649
addComment: {
4750
id: string;
51+
isResolved: boolean;
52+
replies: Pick<Message, 'id'>[];
4853
originalMessage: Message;
54+
insertedAt: string;
55+
updatedAt: string;
56+
metadata: string;
57+
};
58+
};
59+
60+
export type DeleteCommentVariables = {
61+
id: string;
62+
};
63+
64+
export type DeleteCommentResponse = {
65+
deleteComment: {
66+
id: string;
67+
};
68+
};
69+
70+
export type UpdateCommentVariables = {
71+
id: string;
72+
comment?: string;
73+
isResolved?: boolean;
74+
metadata?: string;
75+
};
76+
77+
export type UpdateCommentResponse = {
78+
updateComment: {
79+
id: string;
80+
isResolved: string;
81+
originalMessage: {
82+
id: string;
83+
content: string;
84+
};
4985
};
5086
};
5187

@@ -65,5 +101,6 @@ export type CommentResponse = {
65101
replies: Message[];
66102
insertedAt: string;
67103
updatedAt: string;
104+
metadata: string;
68105
};
69106
};

0 commit comments

Comments
 (0)