Skip to content

Instantly share code, notes, and snippets.

@MrCitron
Created May 23, 2017 09:48
Show Gist options
  • Save MrCitron/bcbbd14bb988133fff6233c4d7e6109f to your computer and use it in GitHub Desktop.
Save MrCitron/bcbbd14bb988133fff6233c4d7e6109f to your computer and use it in GitHub Desktop.
GraphQL to JSON in pure JS
function graphQLToJSON(query) {
return "{\"query\": \"query" +
query.replace(/\n/g, " ").replace(/"/g, "\\\"") +
"\"}";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment