Complete the code to unsubscribe from a GraphQL subscription.
const unsubscribe = subscriptionClient.[1]();The unsubscribe method stops the subscription and cleans up resources.
Complete the code to stop receiving updates by calling the correct method on the subscription object.
const subscription = client.subscribe({ query: MY_SUBSCRIPTION });
subscription.[1]();Calling unsubscribe() on the subscription object stops the updates.
Fix the error in the code to properly unsubscribe from a GraphQL subscription.
const sub = client.subscribe({ query: SUBSCRIPTION_QUERY });
// Incorrect unsubscribe call
sub.[1]();The correct method to stop a subscription is unsubscribe(). Using subscribe() again or other methods will not stop it.
Fill both blanks to correctly create and then unsubscribe from a GraphQL subscription.
const subscription = client.[1]({ query: SUBSCRIPTION }); subscription.[2]();
You first call subscribe to start the subscription, then unsubscribe to stop it.
Fill all three blanks to subscribe, handle data, and then unsubscribe properly.
const subscription = client.[1]({ query: SUBSCRIPTION }); subscription.[2](({ data }) => { console.log(data); }); subscription.[3]();
First, call subscribe to start the subscription and provide a callback to handle data. Finally, call unsubscribe to stop the subscription.