From 69c65c12962ea5d238810b0fcaad2bc1255e60fb Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 7 May 2018 12:59:11 -0400 Subject: [PATCH 1/3] added option to disable rewriting url for graphiql --- .../apollo-server-module-graphiql/src/renderGraphiQL.ts | 8 +++++--- .../src/resolveGraphiQLString.ts | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/apollo-server-module-graphiql/src/renderGraphiQL.ts b/packages/apollo-server-module-graphiql/src/renderGraphiQL.ts index 20fd7e64f7c..6673a44bd3c 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, }; } From 93d6e5ba19aaf7848652f0a9e32287e6fa9a9be0 Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 7 May 2018 13:41:25 -0400 Subject: [PATCH 2/3] updated docs --- CHANGELOG.md | 2 ++ docs/source/graphiql.md | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2b71896b15..872888397b7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ 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. + ### v1.3.6 * Recognize requests with Apollo Persisted Queries and return `PersistedQueryNotSupported` to the client instead of a confusing error. [PR #982](https://github.com/apollographql/apollo-server/pull/982) diff --git a/docs/source/graphiql.md b/docs/source/graphiql.md index 82a4ef11351..99d082b5c57 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 } ``` From 362162fdb7cc2a757b35dd79201cb312fc48a766 Mon Sep 17 00:00:00 2001 From: Jake Date: Mon, 7 May 2018 13:42:30 -0400 Subject: [PATCH 3/3] added link to PR in changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 872888397b7..a792a0a4f00 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +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. +* `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) ### v1.3.6