Skip to content

Commit

Permalink
Update application.js
Browse files Browse the repository at this point in the history
  • Loading branch information
onemanstartup committed Jul 30, 2017
1 parent c92c2b9 commit af152de
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions app/assets/javascripts/graphiql/rails/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,31 @@
//= require ./react-dom-15.5.4
//= require ./fetch-0.10.1
//= require ./graphiql-0.10.2

var parameters = {};

// Defines a GraphQL fetcher using the fetch API.
var graphQLEndpoint = "/graphql";
function graphQLFetcher(graphQLParams) {
return fetch(graphQLEndpoint, {
method: 'post',
headers: {
"Content-Type": "application/json",
"X-CSRF-Token": document.querySelector("meta[name=csrf-token]").getAttribute('content')
},

body: JSON.stringify(graphQLParams),
credentials: 'include',
}).then(function (response) {
return response.json()
});
}
var defaultQuery = undefined
// Render <GraphiQL /> into the body.
ReactDOM.render(
React.createElement(GraphiQL, {
fetcher: graphQLFetcher,
defaultQuery: defaultQuery
}),
document.getElementById("graphiql-container")
);

0 comments on commit af152de

Please sign in to comment.