-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Is there a defaultOptions for Subscription? #11411
Comments
I'm sorry, but at this point we have no such option. You could create your custom const useSubscriptionWithDefaults: typeof useSubscription = (
subscription,
options
) => useSubscription(subscription, { errorPolicy: "myNewDefault", ...options }); |
ah, thanks. Any plans for support it in I can try to make a PR and I'm wondering to know the concerns of adding it? |
Hi @iblislin 👋🏻 is it fair to say that you're looking for something like what's described here? apollographql/apollo-feature-requests#169 If so, the team would be happy to review a PR 🙏🏻 |
Hi @iblislin 👋 Circling back here. Since you're using apollo-angular, you could use a similar approach suggested by @phryneas but in Angular it would look something like: const COMMENTS_SUBSCRIPTION = gql`
subscription onCommentAdded($repoFullName: String!){
commentAdded(repoFullName: $repoFullName){
id
content
}
}
`;
function subscribeWithDefaultOptions(options) {
return apollo.subscribe({
errorPolicy: "myNewDefault",
...options
});
}
@Component({ ... })
class CommentsComponent {
constructor(apollo: Apollo) {
subscribeWithDefaultOptions({
query: COMMENTS_SUBSCRIPTION,
variables: {
repoName: `kamilkisiela/apollo-angular`
}
}).subscribe((result) => {
if (result.data?.commentAdded) {
console.log('New comment:', result.data.commentAdded);
}
});
}
} Since we have a tracking issue for the feature request, I'll go ahead and close this issue out. If you have any other questions, feel free to drop by our Discord, too. Thanks! |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo Client usage and allow us to serve you better. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Hi,
I want to set the default
errorPolicy
for Subscription, but there aren't one for Subscript in the DefaultOptions. Are there any ways to set the default globally?The text was updated successfully, but these errors were encountered: