Skip to content

Commit

Permalink
馃悰 Align apollo-server config with state of embeds (#7432)
Browse files Browse the repository at this point in the history
We added `hideCookieToggle` and `initialState.includeCookies` in the
embedded Sandbox config. We then accidentally added `hideCookieToggle`
to the embedded Explorer, and we should have only added it to the
embedded Sandbox in this repo.

This commit
1. puts `includeCookies` back in the embedded Explorer
2. removes `hideCookieToggle` in the embedded Explorer
3. don't spread the entire config into the explorer config, name the arguments
4. remove redundant `?? undefined`s
  • Loading branch information
mayakoneval committed Mar 9, 2023
1 parent a96aee9 commit 8cbc614
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
13 changes: 13 additions & 0 deletions .changeset/kind-yaks-sneeze.md
@@ -0,0 +1,13 @@
---
'@apollo/server': patch
---

Bug fix: tldr revert a previous change that stops passing includeCookies from the prod landing page config.

Who was affected?

Any Apollo Server instance that passes a `graphRef` to a production landing page with a non-default `includeCookies` value that does not match the `Include cookies` setting on your registered variant on studio.apollographql.com.

How were they affected?

From release 4.4.0 to this patch release, folks affected would have seen their Explorer requests being sent with cookies included only if they had set `Include cookies` on their variant. Cookies would not havhe been included by default.
Expand Up @@ -51,7 +51,7 @@ describe('Embedded Explorer Landing Page Config HTML', () => {
</script>
<script>
var endpointUrl = window.location.href;
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"includeCookies":true,"document":"query Test { id }","variables":{"option":{"a":"val","b":1,"c":true}},"headers":{"authorization":"true"},"embed":{"displayOptions":{"showHeadersAndEnvVars":true,"docsPanelState":"open","theme":"light"},"persistExplorerState":true},"graphRef":"graph@current","displayOptions":{"showHeadersAndEnvVars":true,"docsPanelState":"open","theme":"light"}},"persistExplorerState":true,"hideCookieToggle":false};
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"document":"query Test { id }","headers":{"authorization":"true"},"variables":{"option":{"a":"val","b":1,"c":true}},"displayOptions":{"showHeadersAndEnvVars":true,"docsPanelState":"open","theme":"light"}},"persistExplorerState":true,"includeCookies":true};
new window.EmbeddedExplorer({
...embeddedExplorerConfig,
endpointUrl,
Expand Down Expand Up @@ -89,7 +89,7 @@ describe('Embedded Explorer Landing Page Config HTML', () => {
</script>
<script>
var endpointUrl = window.location.href;
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"includeCookies":false,"embed":true,"graphRef":"graph@current","displayOptions":{}},"persistExplorerState":false,"hideCookieToggle":false};
var embeddedExplorerConfig = {"graphRef":"graph@current","target":"#embeddableExplorer","initialState":{"displayOptions":{}},"persistExplorerState":false,"includeCookies":false};
new window.EmbeddedExplorer({
...embeddedExplorerConfig,
endpointUrl,
Expand Down
Expand Up @@ -42,7 +42,7 @@ export const getEmbeddedExplorerHTML = (

endpointUrl: string;

hideCookieToggle?: boolean; // defaults to 'true'
includeCookies?: boolean; // defaults to 'false'
}
const productionLandingPageConfigOrDefault = {
displayOptions: {},
Expand All @@ -54,14 +54,16 @@ export const getEmbeddedExplorerHTML = (
graphRef: config.graphRef,
target: '#embeddableExplorer',
initialState: {
...config,
document: config.document,
headers: config.headers,
variables: config.variables,
displayOptions: {
...productionLandingPageConfigOrDefault.displayOptions,
},
},
persistExplorerState:
productionLandingPageConfigOrDefault.persistExplorerState,
hideCookieToggle: false,
includeCookies: config.includeCookies,
};

return `
Expand Down Expand Up @@ -117,10 +119,10 @@ id="embeddableSandbox"
target: '#embeddableSandbox',
initialEndpoint,
initialState: ${getConfigStringForHtml({
document: config.document ?? undefined,
variables: config.variables ?? undefined,
headers: config.headers ?? undefined,
includeCookies: config.includeCookies ?? undefined,
document: config.document,
variables: config.variables,
headers: config.headers,
includeCookies: config.includeCookies,
})},
hideCookieToggle: false,
});
Expand Down

0 comments on commit 8cbc614

Please sign in to comment.