react-apollo
                                
                                 react-apollo copied to clipboard
                                
                                    react-apollo copied to clipboard
                            
                            
                            
                        SubscribeToMore's updateQuery is missing its first parameter (previous data equals to null))
Intended outcome: When using subscribeToMore, the first parameter of updateQuery's callback is equal to previous data.
subscribeToMore({
      ......,
      updateQuery: (prev, { subscriptionData }) => {})
      .......
})
prev should equal preivous data
Actual outcome:
subscribeToMore({
      ......,
      updateQuery: (prev, { subscriptionData }) => {})
      .......
})
prev equals to undefined here
Previously, it returned previous data as expected. But now after I modified my Query hook's query (the one with subscribeToMore as a method), prev is undefined. What I did was add 2 extra optional variables which can be empty (it's a string type, so what I mean of empty is "", not null).
These optional variables previously caused some issues when reading cache because I didn't include them (the optional variables), but it's all good now when I include those optional variables with "" value, except for this issue with subscribeToMore.
How to reproduce the issue:
// Apollo GraphQL Hooks
  const { 
    loading, 
    error, 
    data, 
    subscribeToMore, 
    refetch,
    fetchMore
  } = useQuery(getMessageListQuery, { 
    variables: { 
      tenantID: props.phoneNumber, 
      roomID: props.activeChat,
      messageID: "",  // optional variable
      scroll: "" // optional variable
    },
  })
useEffect(() => {
    // subscribe for more messages and create unsubscribe function
    let unsubscribeMessages = subscribeToMore({
      document: subMessageListQuery,
      variables: { 
        to: props.phoneNumber,
        from: props.activeChat 
      },
      updateQuery: (prev, { subscriptionData }) => {
        if (!subscriptionData.data) return prev;
        console.log(prev)
        })
if (unsubscribeMessages) return unsubscribeMessages
  }, [data])
Version
 System:
    OS: macOS Mojave 10.14.6
  Binaries:
    Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
    Yarn: 1.16.0 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
  Browsers:
    Chrome: 77.0.3865.120
    Firefox: 68.0.2
    Safari: 13.0.1
  npmPackages:
    @apollo/react-hooks: ^3.1.0 => 3.1.2 
    @apollo/react-testing: ^3.1.0 => 3.1.1 
    apollo-boost: ^0.4.3 => 0.4.4 
    apollo-client: ^2.6.4 => 2.6.4 
    apollo-link-error: ^1.1.12 => 1.1.12 
    apollo-link-retry: ^2.2.15 => 2.2.15 
    apollo-link-ws: ^1.0.18 => 1.0.18 
I have same problem when having new query result with missing fields.
Same issue. Subscribe is very buggy
up?
I ran into the same issue, it was super stranger because prev suddenly became undefined.
My problem was that I wasn't including some fields in the subscription that I did in the query.