Skip to content

Commit

Permalink
fix: fix boolean value in method
Browse files Browse the repository at this point in the history
  • Loading branch information
Pascal Klesse committed Sep 3, 2024
1 parent bd60ec0 commit 3882f18
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
11 changes: 9 additions & 2 deletions src/runtime/composables/gql-async-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,20 @@ export async function gqlAsyncQuery<T = any>(method: string, options: IGraphQLOp
authorization: `Bearer ${accessTokenState.value}`,
};

const result = await $graphql.default.request(documentNode, variables, requestHeaders);
let result = await $graphql.default.request(documentNode, variables, requestHeaders);

if (!result) {
return result;
}

return result[method] ? result[method] : result;
// check if data[method] is boolean value
if (typeof result[method] === 'boolean') {
result = result[method];
} else {
result = result[method] ? result[method] : result;
}

return result;
},
options.asyncDataOptions,
);
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/composables/gql-mutation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ export async function gqlMutation<T = any>(method: string, options: IGraphQLOpti
data = await $graphql.default.request(documentNode, variables, requestHeaders);

if (data) {
data = data[method] ? data[method] : data;
// check if data[method] is boolean value
if (typeof data[method] === 'boolean') {
data = data[method];
} else {
data = data[method] ? data[method] : data;
}
}
} catch (err) {
console.error('gqlMutation::error ', err);
Expand Down
7 changes: 6 additions & 1 deletion src/runtime/composables/gql-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ export async function gqlQuery<T = any>(method: string, options: IGraphQLOptions
data = await $graphql.default.request(documentNode, variables, requestHeaders);

if (data) {
data = data[method] ? data[method] : data;
// check if data[method] is boolean value
if (typeof data[method] === 'boolean') {
data = data[method];
} else {
data = data[method] ? data[method] : data;
}
}
} catch (err) {
console.error('gqlQuery::error ', err);
Expand Down

0 comments on commit 3882f18

Please sign in to comment.