|
58 | 58 | otherParams[k] = parameters[k];
|
59 | 59 | }
|
60 | 60 | }
|
| 61 | + |
| 62 | + // If there are any fragment parameters, confirm the user wants to use them. |
| 63 | + var isReload = window.performance ? performance.navigation.type === 1 : false; |
| 64 | + var isQueryTrusted = Object.keys(parameters).length === 0 || isReload; |
| 65 | + |
61 | 66 | var fetchURL = locationQuery(otherParams);
|
| 67 | + |
62 | 68 | // Defines a GraphQL fetcher using the fetch API.
|
63 | 69 | function graphQLFetcher(graphQLParams) {
|
| 70 | + var isIntrospectionQuery = ( |
| 71 | + graphQLParams.query !== parameters.query |
| 72 | + && graphQLParams.query.indexOf('IntrospectionQuery') !== -1 |
| 73 | + ); |
| 74 | + |
| 75 | + if (!isQueryTrusted |
| 76 | + && !isIntrospectionQuery |
| 77 | + && !window.confirm("This query was loaded from a link, are you sure you want to execute it?")) { |
| 78 | + return Promise.resolve('Aborting query.'); |
| 79 | + } |
| 80 | + |
| 81 | + // We don't want to set this for the introspection query |
| 82 | + if (!isIntrospectionQuery) { |
| 83 | + isQueryTrusted = true; |
| 84 | + } |
| 85 | + |
64 | 86 | var headers = {
|
65 | 87 | 'Accept': 'application/json',
|
66 | 88 | 'Content-Type': 'application/json'
|
|
100 | 122 | function updateURL() {
|
101 | 123 | history.replaceState(null, null, locationQuery(parameters));
|
102 | 124 | }
|
103 |
| - // If there are any fragment parameters, confirm the user wants to use them. |
104 |
| - var isReload = window.performance ? performance.navigation.type === 1 : false; |
105 |
| - if (Object.keys(parameters).length |
106 |
| - && !isReload |
107 |
| - && !window.confirm("An untrusted query has been loaded, continue loading query?")) { |
108 |
| - parameters = {}; |
109 |
| - } |
110 | 125 | var options = {
|
111 | 126 | fetcher: graphQLFetcher,
|
112 | 127 | onEditQuery: onEditQuery,
|
|
0 commit comments