Skip to content

Commit

Permalink
Merge pull request #305 from NibiruChain/develop
Browse files Browse the repository at this point in the history
fix: mutation logic again
  • Loading branch information
cgilbe27 authored Feb 5, 2024
2 parents b7656a7 + c77f4d3 commit 62a9b31
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
23 changes: 13 additions & 10 deletions src/gql/mutation/marketing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ export const marketingMutationString = (
excludeParentObject: boolean,
fields?: Partial<GQLTwitterUser>
) =>
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<MutationMarketingArgs>,
Expand All @@ -40,5 +42,6 @@ export const marketingMutation = async (
doGqlQuery(
marketingMutationString(args, false, fields),
endpt,
authorizationHeader
authorizationHeader,
true
)
7 changes: 5 additions & 2 deletions src/gql/utils/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,15 @@ export const gqlQuery = <T>(
export const doGqlQuery = async <T>(
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
}

1 comment on commit 62a9b31

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines Statements Branches Functions
Coverage: 93%
94.62% (1197/1265) 87.58% (543/620) 88.03% (309/351)

Please sign in to comment.