Skip to content

Commit

Permalink
useSubscription: clarify shouldResubscribe and document onError (
Browse files Browse the repository at this point in the history
…#10454)

* Add `onError` and clarify `shouldResubscribe`

* Remove extra commas

Co-authored-by: Jeff Auriemma <bignimbus@users.noreply.github.com>
  • Loading branch information
dylanfprice and bignimbus authored Jan 19, 2023
1 parent 29ff9f6 commit 00cf63f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions docs/shared/subscription-options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@
| - | - | - |
| `subscription` | DocumentNode | A GraphQL subscription document parsed into an AST by `graphql-tag`. **Optional** for the `useSubscription` Hook since the subscription can be passed in as the first parameter to the Hook. **Required** for the `Subscription` component. |
| `variables` | { [key: string]: any } | An object containing all of the variables your subscription needs to execute |
| `shouldResubscribe` | boolean | Determines if your subscription should be unsubscribed and subscribed again |
| `shouldResubscribe` | boolean | Determines if your subscription should be unsubscribed and subscribed again when an input to the hook (such as `subscription` or `variables`) changes. |
| `skip` | boolean | Determines if the current subscription should be skipped. Useful if, for example, variables depend on previous queries and are not ready yet. |
| `onSubscriptionData` | **Deprecated.** (options: OnSubscriptionDataOptions&lt;TData&gt;) => any | Allows the registration of a callback function, that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `subscriptionData`. |
| `onData` | (options: OnDataOptions&lt;TData&gt;) => any | Allows the registration of a callback function, that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`. |
| `onSubscriptionComplete` | **Deprecated.** () => void | Allows the registration of a callback function, that will be triggered when the `useSubscription` Hook / `Subscription` component completes the subscription. |
| `onComplete` | () => void | Allows the registration of a callback function, that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription. |
| `onSubscriptionData` | **Deprecated.** (options: OnSubscriptionDataOptions&lt;TData&gt;) => any | Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `subscriptionData`. |
| `onData` | (options: OnDataOptions&lt;TData&gt;) => any | Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives data. The callback `options` object param consists of the current Apollo Client instance in `client`, and the received subscription data in `data`. |
| `onError` | (error: ApolloError) => void | Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component receives an error. |
| `onSubscriptionComplete` | **Deprecated.** () => void | Allows the registration of a callback function that will be triggered when the `useSubscription` Hook / `Subscription` component completes the subscription. |
| `onComplete` | () => void | Allows the registration of a callback function that will be triggered each time the `useSubscription` Hook / `Subscription` component completes the subscription. |
| `fetchPolicy` | FetchPolicy | How you want your component to interact with the Apollo cache. For details, see [Setting a fetch policy](/react/data/queries/#setting-a-fetch-policy). |
| `context` | Record&lt;string, any&gt; | Shared context between your component and your network interface (Apollo Link). |
| `client` | ApolloClient | An `ApolloClient` instance. By default `useSubscription` / `Subscription` uses the client passed down via context, but a different client can be passed in. |

0 comments on commit 00cf63f

Please sign in to comment.