Skip to content

Commit 428c9bf

Browse files
authored
Merge pull request #400 from bakaphp/hot-fix
fix
2 parents f8ec1a7 + 9160b1b commit 428c9bf

File tree

4 files changed

+42
-37
lines changed

4 files changed

+42
-37
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.30.3",
2+
"version": "0.30.4",
33
"license": "MIT",
44
"main": "dist/index.js",
55
"typings": "dist/index.d.ts",

src/modules/messages/index.ts

+12-18
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
AllLikedMessagesByUser,
1717
AllForYouMessages,
1818
AllChannelMessages,
19+
MessageWithFileInputInterface,
1920
} from '../../types';
2021
import {
2122
CREATE_MESSAGE_MUTATION,
@@ -30,6 +31,7 @@ import {
3031
VIEW_MESSAGE_MUTATION,
3132
DISLIKE_MESSAGE_MUTATION,
3233
RESTORE_MESSAGE_MUTATION,
34+
CREATE_MESSAGE_WITH_FILE_MUTATION,
3335
} from '../../mutations';
3436

3537
import {
@@ -79,7 +81,10 @@ export class Messages {
7981
return (await response).data.createMessage as MessagesInterface;
8082
}
8183

82-
public async createMessageWithFile(file: File, input: any): Promise<any> {
84+
public async createMessageWithFile(
85+
file: File,
86+
input: MessageWithFileInputInterface
87+
): Promise<any> {
8388
if (!this.options || !this.axiosClient)
8489
throw new Error('FileSystem module not initialized');
8590

@@ -88,28 +93,17 @@ export class Messages {
8893
formData.append(
8994
'operations',
9095
JSON.stringify({
91-
query: `
92-
mutation ($file: Upload!, $input: MessageInput!) {
93-
createMessage(input: $input) {
94-
id
95-
message
96-
user { id }
97-
parent { id }
98-
messageType { id }
99-
reactions_count
100-
tags { data { name } }
101-
files { data { id, uuid, name, url } }
102-
}
103-
}
104-
`,
96+
query: CREATE_MESSAGE_WITH_FILE_MUTATION,
10597
variables: {
106-
file: null,
107-
input,
98+
input: {
99+
...input,
100+
files: null,
101+
},
108102
},
109103
})
110104
);
111105

112-
formData.append('map', JSON.stringify({ '0': ['variables.file'] }));
106+
formData.append('map', JSON.stringify({ '0': ['variables.input.files'] }));
113107
formData.append('0', file, file.name);
114108

115109
const response = await this.axiosClient.post('', formData);

src/mutations/messages.mutation.ts

+19-18
Original file line numberDiff line numberDiff line change
@@ -32,35 +32,36 @@ export const CREATE_MESSAGE_MUTATION = gql`
3232
}
3333
`;
3434

35-
export const CREATE_MESSAGE_MUTATION_V2 = gql`
36-
mutation($file: Upload!) {
37-
createMessage(
38-
input: {
39-
message_verb: "EXE"
40-
message: {
41-
name: "John Doe"
42-
for_review: true
43-
is_reviewed: false
44-
text: "Sample message text"
45-
}
46-
entity_id: "550e8400-e29b-41d4-a716-446655440000"
47-
tags: [{ name: "test" }, { name: "test2" }]
48-
is_public: 1
49-
files: [$file]
50-
}
51-
) {
35+
export const CREATE_MESSAGE_WITH_FILE_MUTATION = `
36+
mutation createMessage($input: MessageInput!) {
37+
createMessage(input: $input) {
5238
id
39+
uuid
40+
slug
5341
message
42+
parent_id
43+
total_liked
44+
total_saved
45+
comment_count
46+
message_types_id
47+
reactions_count
5448
user {
5549
id
50+
firstname
51+
lastname
52+
displayname
53+
}
54+
appModuleMessage {
55+
entity_id
56+
system_modules
5657
}
5758
parent {
5859
id
60+
uuid
5961
}
6062
messageType {
6163
id
6264
}
63-
reactions_count
6465
tags {
6566
data {
6667
name

src/types/messages.ts

+10
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,16 @@ export interface MessageInputInterface {
8989
distribution?: DistributionInputInterface;
9090
}
9191

92+
export interface MessageWithFileInputInterface {
93+
message_verb: string;
94+
message: any;
95+
system_modules_id?: string;
96+
entity_id?: string;
97+
parent_id?: string;
98+
distribution?: DistributionInputInterface;
99+
files: File[];
100+
}
101+
92102
export interface MessageUpdateInputInterface {
93103
message: string;
94104
message_verb?: string;

0 commit comments

Comments
 (0)