Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cell-suspense): pass through variables if passed to refetch #9965

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions packages/web/src/components/cell/cellTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,26 +212,6 @@ export interface SuspenseCellQueryResult<
> extends UseBackgroundQueryResult {
client: ApolloClient<any>
// fetchMore & refetch come from UseBackgroundQueryResult

// not supplied in Error and Failure
// because it's implicit in these components, but the one edgecase is showing a different loader when refetching
networkStatus?: NetworkStatus
called: boolean // can we assume if we have a queryRef its called?

// Stuff not here compared to useQuery:
// observable: ObservableQuery<TData, TVariables> // Lenz: internal implementation detail, should not be required anymore
// previousData?: TData, // emulating suspense, not required in the new Suspense model

// ObservableQueryFields 👇
// subscribeToMore ~ returned from useSuspenseQuery but not useReadQuery. Apollo team **may** expose from useReadQuery.
// updateQuery <~ May not be necessary in the Suspense model
// refetch ~ <~ refetch signature is different in useQuery vs useSuspenseQuery. Apollo team need an internal discussion.
// reobserve <~ avoid
// variables <~ variables passed to the query, useful if you updated the variables using updateQuery or refetch. Apollo team need an internal discussion.

// Polling: Apollo team are not ready to expose Polling yet. Unlikely to be shipped in the next few months.
// But possible to re-implement this in a different way using setInternal or client.startPolling
// startPolling
// stopPolling
// ~~~
called: boolean // set if queryRef present
}
6 changes: 3 additions & 3 deletions packages/web/src/components/cell/createSuspendingCell.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Suspense } from 'react'

import type { QueryReference } from '@apollo/client'
import type { OperationVariables, QueryReference } from '@apollo/client'
import { useApolloClient } from '@apollo/client'

import { useBackgroundQuery, useReadQuery } from '../GraphQLHooksProvider'
Expand Down Expand Up @@ -112,9 +112,9 @@ export function createSuspendingCell<

const queryResultWithErrorReset = {
...suspenseQueryResult,
refetch: () => {
refetch: (variables: Partial<OperationVariables> | undefined) => {
resetErrorBoundary()
return suspenseQueryResult.refetch?.()
return suspenseQueryResult.refetch?.(variables)
},
}

Expand Down
Loading