Skip to content

Commit

Permalink
Merge pull request #42 from wp-graphql/fix/graphiql-get-requests-failing
Browse files Browse the repository at this point in the history
fix: miniGraphiQL component GET requests have undefined query and variables
  • Loading branch information
jasonbahl authored Dec 20, 2023
2 parents f4f99c7 + cb6e9e3 commit fcff559
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions components/MiniGraphiQL.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,22 @@ const MiniGraphiQLClient = ({ initialQuery, initialVariables, endpoint, readOnly
const fetcher = createGraphiQLFetcher({
url: endpoint,
fetch: async (url, options) => {
// Construct query parameters
const params = new URLSearchParams({
query: options.body.query,
variables: JSON.stringify(options.body.variables),
});
const parsedBody = JSON.parse(options?.body);

const params = new URLSearchParams();
params.append('query', parsedBody.query);
if (options.body.variables) {
params.append('variables', JSON.stringify(parsedBody.variables));
}
const getUrl = `${url}&${params.toString()}`;

// Make the GET request
return fetch(`${url}?${params.toString()}`, {
const res = await fetch(getUrl, {
method: 'GET',
headers: { 'Accept': 'application/json' }
headers: options?.headers,
});

return res;
}
});

Expand Down

1 comment on commit fcff559

@headless-platform-by-wp-engine

Choose a reason for hiding this comment

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

Check out the recent updates to your Atlas environment:

App Environment URL Build
acf.wpgraphql.com main https://hb…wered.com ✅ (logs)

Learn more about building on Atlas in our documentation.

Please sign in to comment.