From 2ac3f0128cd568d2ed7bab6cca7d5c74f7c30b42 Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Mon, 5 Feb 2024 16:18:55 -0500 Subject: [PATCH 1/2] fix: fix --- src/gql/mutation/marketing.ts | 20 +++++++++++--------- src/gql/utils/consts.ts | 7 +++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/gql/mutation/marketing.ts b/src/gql/mutation/marketing.ts index 4adef99b..b767f305 100644 --- a/src/gql/mutation/marketing.ts +++ b/src/gql/mutation/marketing.ts @@ -21,15 +21,17 @@ export const marketingMutationString = ( excludeParentObject: boolean, fields?: Partial ) => - gqlQuery( - "marketing", - args, - fields - ? convertObjectToPropertiesString(fields) - : convertObjectToPropertiesString(defaultTwitterUser), - excludeParentObject, - true - ) + `marketing { + ${gqlQuery( + "updateTwitterUser", + args, + fields + ? convertObjectToPropertiesString(fields) + : convertObjectToPropertiesString(defaultTwitterUser), + excludeParentObject, + true + )} + }` export const marketingMutation = async ( args: Partial, diff --git a/src/gql/utils/consts.ts b/src/gql/utils/consts.ts index eef256fa..0ecf80e0 100644 --- a/src/gql/utils/consts.ts +++ b/src/gql/utils/consts.ts @@ -132,12 +132,15 @@ export const gqlQuery = ( export const doGqlQuery = async ( gqlQuery: string, gqlEndpt: string, - headers?: HeadersInit + headers?: HeadersInit, + isMutation?: boolean ) => { const rawResp = await fetch(gqlEndpt, { method: "POST", headers: { "Content-Type": "application/json", ...headers }, - body: JSON.stringify({ query: gqlQuery }), + body: JSON.stringify( + isMutation ? { mutation: gqlQuery } : { query: gqlQuery } + ), }) return cleanResponse(rawResp) as T } From c77f4d37469273906e41507114c78297d8d2152e Mon Sep 17 00:00:00 2001 From: Cameron Gilbert Date: Mon, 5 Feb 2024 16:19:27 -0500 Subject: [PATCH 2/2] fix: fix --- src/gql/mutation/marketing.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gql/mutation/marketing.ts b/src/gql/mutation/marketing.ts index b767f305..b43410cd 100644 --- a/src/gql/mutation/marketing.ts +++ b/src/gql/mutation/marketing.ts @@ -42,5 +42,6 @@ export const marketingMutation = async ( doGqlQuery( marketingMutationString(args, false, fields), endpt, - authorizationHeader + authorizationHeader, + true )