diff --git a/CHANGELOG.md b/CHANGELOG.md index bb793d6f07d..fecc8a2c3cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ All of the packages in the `apollo-server` repo are released with the same versi ### vNEXT +* `apollo-server-module-graphiql`: adds an option to the constructor to disable url rewriting when editing a query [PR #1047](https://github.com/apollographql/apollo-server/pull/1047) * Upgrade `subscription-transport-ws` to 0.9.9 for Graphiql ### v1.3.6 diff --git a/docs/source/graphiql.md b/docs/source/graphiql.md index 98d740cf1bd..abe72017645 100644 --- a/docs/source/graphiql.md +++ b/docs/source/graphiql.md @@ -18,6 +18,7 @@ const options = { result?: Object, // optional result to pre-populate the GraphiQL UI with passHeader?: String, // a string that will be added to the outgoing request header object (e.g "'Authorization': 'Bearer lorem ipsum'") editorTheme?: String, // optional CodeMirror theme to be applied to the GraphiQL UI + rewriteURL?: Boolean, // optionally turn off url rewriting when editing queries } ``` diff --git a/packages/apollo-server-module-graphiql/src/renderGraphiQL.ts b/packages/apollo-server-module-graphiql/src/renderGraphiQL.ts index 8bb57bf3c63..1cfdf95b694 100644 --- a/packages/apollo-server-module-graphiql/src/renderGraphiQL.ts +++ b/packages/apollo-server-module-graphiql/src/renderGraphiQL.ts @@ -30,6 +30,7 @@ export type GraphiQLData = { passHeader?: string; editorTheme?: string; websocketConnectionParams?: Object; + rewriteURL?: boolean; }; // Current latest version of GraphiQL. @@ -62,6 +63,7 @@ export function renderGraphiQL(data: GraphiQLData): string { const editorTheme = data.editorTheme; const usingEditorTheme = !!editorTheme; const websocketConnectionParams = data.websocketConnectionParams || null; + const rewriteURL = !!data.rewriteURL; /* eslint-disable max-len */ return ` @@ -199,15 +201,15 @@ export function renderGraphiQL(data: GraphiQLData): string { // that it can be easily shared. function onEditQuery(newQuery) { parameters.query = newQuery; - updateURL(); + ${rewriteURL ? 'updateURL();' : ''} } function onEditVariables(newVariables) { parameters.variables = newVariables; - updateURL(); + ${rewriteURL ? 'updateURL();' : ''} } function onEditOperationName(newOperationName) { parameters.operationName = newOperationName; - updateURL(); + ${rewriteURL ? 'updateURL();' : ''} } function updateURL() { var cleanParams = Object.keys(parameters).filter(function(v) { diff --git a/packages/apollo-server-module-graphiql/src/resolveGraphiQLString.ts b/packages/apollo-server-module-graphiql/src/resolveGraphiQLString.ts index 347f77e189b..8aeb0c45aa3 100644 --- a/packages/apollo-server-module-graphiql/src/resolveGraphiQLString.ts +++ b/packages/apollo-server-module-graphiql/src/resolveGraphiQLString.ts @@ -48,6 +48,7 @@ function createGraphiQLData( passHeader: options.passHeader, editorTheme: options.editorTheme, websocketConnectionParams: options.websocketConnectionParams, + rewriteURL: options.rewriteURL, }; }