-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Description
skip as an option for suspense hooks is going to be deprecated in favour of a new skipToken technique in an upcoming version of Apollo, as it provides more type safety.
Apollo docs on skip:
This option is deprecated and only supported to ease the migration from useQuery. It will be removed in a future release. Please use skipToken instead of the skip option as it is more type-safe.
More reading:
- https://www.apollographql.com/docs/react/data/suspense/#skipping-suspense-hooks
- https://www.apollographql.com/docs/react/api/react/hooks/#skiptoken
You can work around this at the moment by using useSuspenseQuery directly from @apollo/client and using the document and types generated by graphql-code-generator, eg:
import { useSuspenseQuery, skipToken } from '@apollo/client'
import { ExampleQueryResult, ExampleQueryDocument } from './generated'`
const { data } = useSuspenseQuery<ExampleQueryResult>(
ExampleQueryDocument,
id ? { variables: { id } } : skipToken
)
Describe the solution you'd like
It would great if the generated suspense hook had native support for this (which aligns with what their docs recommend), eg:
import { skipToken } from '@apollo/client'
import { useExampleSuspenseQuery } from './generated'`
const { data } = useExampleSuspenseQuery(id ? { variables: { id } } : skipToken)
vbornand, PaulinL, mvdstam, rozsival, mkupiniak and 2 more
Metadata
Metadata
Assignees
Labels
No labels