From 5d5d002bd08a04b8c1cedb7dc78e16546ad9a5c4 Mon Sep 17 00:00:00 2001 From: Victor Raposo Date: Wed, 21 Aug 2019 19:26:39 -0300 Subject: [PATCH] Keeps querystring in navigations --- react/components/RenderProvider.tsx | 10 ++++++++-- react/utils/routes.ts | 12 ++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/react/components/RenderProvider.tsx b/react/components/RenderProvider.tsx index f5d50f4a0..ce572a4d1 100644 --- a/react/components/RenderProvider.tsx +++ b/react/components/RenderProvider.tsx @@ -18,6 +18,8 @@ import PageCacheControl from '../utils/cacheControl' import { getClient } from '../utils/client' import { OperationContext } from '../utils/client/links/uriSwitchLink' import { traverseComponent } from '../utils/components' +import queryString from 'query-string' + import { isSiteEditorIframe, RENDER_CONTAINER_CLASS, @@ -559,7 +561,10 @@ class RenderProvider extends Component { // well as the fields that need to be retrieved, but the logic // that the new state (extensions and assets) will be derived from // the results of this query will probably remain the same. - return fetchNavigationPage({ path: navigationRoute.path }).then( + return fetchNavigationPage({ + path: navigationRoute.path, + query: queryString.stringify(query || {}), + }).then( ({ appsEtag, components, @@ -706,7 +711,7 @@ class RenderProvider extends Component { } public updateRuntime = async () => { - const { page, route } = this.state + const { page, route, query } = this.state const { appsEtag, cacheHints, @@ -717,6 +722,7 @@ class RenderProvider extends Component { settings, } = await fetchNavigationPage({ path: route.path, + query: queryString.stringify(query || {}), }) await new Promise(resolve => { diff --git a/react/utils/routes.ts b/react/utils/routes.ts index 24cee66ca..958cb33ed 100644 --- a/react/utils/routes.ts +++ b/react/utils/routes.ts @@ -128,10 +128,18 @@ const runtimeFields = [ 'settings', ].join(',') -export const fetchNavigationPage = ({ path }: { path: string }) => - fetch(`${path}?__pickRuntime=${runtimeFields}`) +export const fetchNavigationPage = ({ + path, + query, +}: { + path: string + query: string +}) => { + console.log({ query }) + return fetch(`${path}?${query}&__pickRuntime=${runtimeFields}`) .then(response => response.json()) .then(parsePageQueryResponse) +} export const fetchNavigationPageOld = ({ apolloClient,