When should you use shouldResubscribe?

I’m using graphql in a project, and I’m trying to understand the best practices when it comes to subscriptions. When should you use shouldResubscribe? When shouldn’t you? I’ve been trying to find information about resubscribing, but I haven’t found that much information.

Specifically I’m trying to figure out whether it would be useful if you delete a post that’s contained within the subscribed data:

Currently I have:

export const GET_POST = gql`
  query ($offset: Int!, $topic: String) {
    getMessage(offset: $offset, limit: 20, topic: $topic) {
     _id
     sender {
       senderId
     }
      post {
        text
        topic
        dateSent
      }
    }
  }
`;

export const CREATE_POST_MUTATION = gql`
  mutation createPost($input: PostInput!) {
    createPost(input: $input) {
        post {
          text
          dateSent
        }
      }
  }
`;

export const POST_SUBSCRIPTION = gql`
subscription {
  _id
  newPost {
    sender {
      senderId
    }
     post {
       text
        topic
       dateSent
     }
   } 
  }
`;

export default function PostScreen() {

const [createPost,{ data: createPostDate, error:createPostError}] = useMutation(CREATE_POST_MUTATION)
  async function createPostHandler (item: any) {
    createPost({
    variables: { 
    input: { 
       ...
   }, 
  }})
  }
const {data, loading, error, subscribeToMore, fetchMore: fetchMorePosts} = useQuery(GET_POST,  {fetchPolicy: 'cache-and-network', variables: { offset: 0, topic: ''}})

 useEffect(() => {
  subscribeToMore({
     document: POST_SUBSCRIPTION,
      updateQuery: (prev, { subscriptionData }) => {
         if (!subscriptionData) {
            return prev;
          }
          const updatePost = subscriptionData.data.updatePost.data;
          const action = subscriptionData.data.updatePost.action;
          if (action === "CREATE") {
              return {
                 getPost:[updatePost, ...prev.getPost]
              };
          }
          else if (action === "DELETE"){
            getPost ...
         },
        onError: err => console.error(err)
      });
}, []);

And I’m trying to figure out if it would be considered a good practice/ efficient to resubscribe if action === "DELETE".

shouldResubscribe is true by default, so you don’t have any need to specify it if you don’t explicitly want to turn it off.

Generally, you’d only want to turn that off if you don’t want the subscription to change when you change e.g. variables.

You can probably safely ignore that option in almost all cases.