Skip to content

Commit

Permalink
Pass options from the fragment, not the template context
Browse files Browse the repository at this point in the history
  • Loading branch information
danpalmer committed Aug 30, 2018
1 parent 3755850 commit 0d8f9db
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions graphene_django/templates/graphene/graphiql.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,22 +100,27 @@
function updateURL() {
history.replaceState(null, null, locationQuery(parameters));
}
// Render <GraphiQL /> into the body.
ReactDOM.render(
React.createElement(GraphiQL, {
fetcher: graphQLFetcher,
// If there are any fragment parameters, confirm the user wants to use them.
if (Object.keys(parameters).length
&& !window.confirm("An untrusted query has been loaded, continue loading query?")) {
parameters = {};
}
var options = {
fetcher: graphQLFetcher,
onEditQuery: onEditQuery,
onEditVariables: onEditVariables,
onEditOperationName: onEditOperationName,
query: '{{ query|escapejs }}',
response: '{{ result|escapejs }}',
{% if variables %}
variables: '{{ variables|escapejs }}',
{% endif %}
{% if operation_name %}
operationName: '{{ operation_name|escapejs }}',
{% endif %}
}),
query: parameters.query,
}
if (parameters.variables) {
options.variables = parameters.variables;
}
if (parameters.operation_name) {
options.operationName = parameters.operation_name;
}
// Render <GraphiQL /> into the body.
ReactDOM.render(
React.createElement(GraphiQL, options),
document.body
);
</script>
Expand Down

0 comments on commit 0d8f9db

Please sign in to comment.