Skip to content

Commit

Permalink
Keeps querystring in navigations
Browse files Browse the repository at this point in the history
  • Loading branch information
vwraposo committed Aug 22, 2019
1 parent 0bff910 commit 5d5d002
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
10 changes: 8 additions & 2 deletions react/components/RenderProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -559,7 +561,10 @@ class RenderProvider extends Component<Props, RenderProviderState> {
// 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,
Expand Down Expand Up @@ -706,7 +711,7 @@ class RenderProvider extends Component<Props, RenderProviderState> {
}

public updateRuntime = async () => {
const { page, route } = this.state
const { page, route, query } = this.state
const {
appsEtag,
cacheHints,
Expand All @@ -717,6 +722,7 @@ class RenderProvider extends Component<Props, RenderProviderState> {
settings,
} = await fetchNavigationPage({
path: route.path,
query: queryString.stringify(query || {}),
})

await new Promise<void>(resolve => {
Expand Down
12 changes: 10 additions & 2 deletions react/utils/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 5d5d002

Please sign in to comment.