Skip to content

Instantly share code, notes, and snippets.

@thelebster
Created March 15, 2019 03:45
Show Gist options
  • Select an option

  • Save thelebster/ac2cbc74f674bc88f4bbdde4954c83a1 to your computer and use it in GitHub Desktop.

Select an option

Save thelebster/ac2cbc74f674bc88f4bbdde4954c83a1 to your computer and use it in GitHub Desktop.
Allows to debug GraphQL queries with jQuery AJAX in Crome console.
let query = `
query {
someQuery {
id
title
body
}
}
`;
let variables = {
};
var settings = {
"async": true,
"crossDomain": true,
"url": "https://example.com/graphql",
"method": "POST",
"headers": {
"Content-Type": "application/json",
"Authorization": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1NTI1ODEzNzMsImV4cCI6MTU1MjU4NDk3MywidWlkIjoiNzkiLCJkcnVwYWwiOnsidWlkIjoiNzkifX0.jAl7wRZi6fQr-45DQPMJocrc8xz_1ORQK97R0mb2alM",
"cache-control": "no-cache"
},
"data": JSON.stringify({query, variables})
}
jQuery.ajax(settings).done(function (response) {
console.log(response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment