|
100 | 100 | function updateURL() {
|
101 | 101 | history.replaceState(null, null, locationQuery(parameters));
|
102 | 102 | }
|
103 |
| - // Render <GraphiQL /> into the body. |
104 |
| - ReactDOM.render( |
105 |
| - React.createElement(GraphiQL, { |
106 |
| - fetcher: graphQLFetcher, |
| 103 | + // If there are any fragment parameters, confirm the user wants to use them. |
| 104 | + if (Object.keys(parameters).length |
| 105 | + && !window.confirm("An untrusted query has been loaded, continue loading query?")) { |
| 106 | + parameters = {}; |
| 107 | + } |
| 108 | + var options = { |
| 109 | + fetcher: graphQLFetcher, |
107 | 110 | onEditQuery: onEditQuery,
|
108 | 111 | onEditVariables: onEditVariables,
|
109 | 112 | onEditOperationName: onEditOperationName,
|
110 |
| - query: '{{ query|escapejs }}', |
111 |
| - response: '{{ result|escapejs }}', |
112 |
| - {% if variables %} |
113 |
| - variables: '{{ variables|escapejs }}', |
114 |
| - {% endif %} |
115 |
| - {% if operation_name %} |
116 |
| - operationName: '{{ operation_name|escapejs }}', |
117 |
| - {% endif %} |
118 |
| - }), |
| 113 | + query: parameters.query, |
| 114 | + } |
| 115 | + if (parameters.variables) { |
| 116 | + options.variables = parameters.variables; |
| 117 | + } |
| 118 | + if (parameters.operation_name) { |
| 119 | + options.operationName = parameters.operation_name; |
| 120 | + } |
| 121 | + // Render <GraphiQL /> into the body. |
| 122 | + ReactDOM.render( |
| 123 | + React.createElement(GraphiQL, options), |
119 | 124 | document.body
|
120 | 125 | );
|
121 | 126 | </script>
|
|
0 commit comments