Skip to content

Commit

Permalink
fix: graph query fetcher (#877)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfshao authored Jul 8, 2021
1 parent de318d6 commit 73fd973
Showing 1 changed file with 19 additions and 21 deletions.
40 changes: 19 additions & 21 deletions src/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,28 +184,26 @@ export const fetchWrapper = ({
},
);

export const fetchGraphQL = (graphQLParams) => {
// We first update the session so that the user will be notified
// if their auth is insufficient to perform the query.
sessionMonitor.updateSession().then(() => {
const request = {
credentials: 'include',
headers: { ...headers },
method: 'POST',
body: JSON.stringify(graphQLParams),
};
// We first update the session so that the user will be notified
// if their auth is insufficient to perform the query.
export const fetchGraphQL = (graphQLParams) => sessionMonitor.updateSession().then(() => {
const request = {
credentials: 'include',
headers: { ...headers },
method: 'POST',
body: JSON.stringify(graphQLParams),
};

return fetch(graphqlPath, request)
.then((response) => response.text())
.then((responseBody) => {
try {
return JSON.parse(responseBody);
} catch (error) {
return responseBody;
}
});
});
};
return fetch(graphqlPath, request)
.then((response) => response.text())
.then((responseBody) => {
try {
return JSON.parse(responseBody);
} catch (error) {
return responseBody;
}
});
});

export const fetchFlatGraphQL = (graphQLParams) => sessionMonitor.updateSession().then(() => {
const request = {
Expand Down

0 comments on commit 73fd973

Please sign in to comment.