diff --git a/src/context/editor.tsx b/src/context/editor.tsx index 83992474..7db797e2 100644 --- a/src/context/editor.tsx +++ b/src/context/editor.tsx @@ -122,20 +122,11 @@ export const EditorProvider = (props: { children: JSX.Element }) => { const updateShout = async (formToUpdate: ShoutForm, { publish }: { publish: boolean }) => { return await apiClient.updateArticle({ - shoutId: formToUpdate.shoutId, - shoutInput: { - body: formToUpdate.body, + shout_id: formToUpdate.shoutId, + shout_input: { + ...formToUpdate, topics: formToUpdate.selectedTopics.map((topic) => topic2topicInput(topic)), // NOTE: first is main - // authors?: InputMaybe>> - // community?: InputMaybe - // mainTopic: topic2topicInput(formToUpdate.mainTopic), - slug: formToUpdate.slug, - subtitle: formToUpdate.subtitle, - title: formToUpdate.title, - lead: formToUpdate.lead, - description: formToUpdate.description, cover: formToUpdate.coverImageUrl, - media: formToUpdate.media, }, publish, }) @@ -204,10 +195,10 @@ export const EditorProvider = (props: { children: JSX.Element }) => { } } - const publishShoutById = async (shoutId: number) => { + const publishShoutById = async (shout_id: number) => { try { await apiClient.updateArticle({ - shoutId, + shout_id, publish: true, }) diff --git a/src/graphql/client/core.ts b/src/graphql/client/core.ts index 04e8acf6..54a39ed3 100644 --- a/src/graphql/client/core.ts +++ b/src/graphql/client/core.ts @@ -149,16 +149,16 @@ export const apiClient = { return response.data.create_shout.shout }, updateArticle: async ({ - shoutId, - shoutInput, + shout_id, + shout_input, publish, }: { - shoutId: number - shoutInput?: ShoutInput + shout_id: number + shout_input?: ShoutInput publish: boolean }): Promise => { const response = await apiClient.private - .mutation(updateArticle, { shoutId, shoutInput, publish }) + .mutation(updateArticle, { shout_id, shout_input, publish }) .toPromise() console.debug('[graphql.client.core] updateArticle:', response.data) return response.data.update_shout.shout diff --git a/src/graphql/mutation/core/article-update.ts b/src/graphql/mutation/core/article-update.ts index ca455bc5..24629b07 100644 --- a/src/graphql/mutation/core/article-update.ts +++ b/src/graphql/mutation/core/article-update.ts @@ -1,8 +1,8 @@ import { gql } from '@urql/core' export default gql` - mutation UpdateShoutMutation($shoutId: Int!, $shoutInput: ShoutInput, $publish: Boolean) { - update_shout(shout_id: $shoutId, shout_input: $shoutInput, publish: $publish) { + mutation UpdateShoutMutation($shout_id: Int!, $shout_input: ShoutInput, $publish: Boolean) { + update_shout(shout_id: $shout_id, shout_input: $shout_input, publish: $publish) { error shout { id