为什么GraphQL订阅将在更新时删除查询?

时间:2019-08-21 09:55:09

标签: javascript graphql

我有以下订阅,但是当我收到某些内容并尝试更新查询时,它将被删除。知道我在这做错了什么吗?除此以外,我所有的订阅都运行良好,唯一的区别是我收到的是数组而不是对象。

if (nextProps.getSkills && !nextProps.getSkills.loading) {
  let { subscribeToMore } = this.props.getSkills;
  subscribeToMore({
    document: SKILLS_ENDORSED_SUBSCRIPTION,
    updateQuery: (prev, { subscriptionData }) => {
      if (!subscriptionData.data) {
        return prev;
      }

      const endorsedSkills = subscriptionData.data.skillsEndorsed;

      if (endorsedSkills) {
        return {
          ...prev,
          getUserSkills: [...endorsedSkills, ...prev.getUserSkills]
        };
      }

      return prev;
    },
    onError: err => console.log(err)
  });
}

我的更新查询

Object {
  "error": undefined,
  "fetchMore": [Function bound ],
  "getUserSkills": Array [], // When I update this will be removed
  "loading": false,
  "networkStatus": 7,
  "refetch": [Function bound ],
  "startPolling": [Function bound ],
  "stopPolling": [Function bound ],
  "subscribeToMore": [Function bound ],
  "updateQuery": [Function bound ],
  "variables": Object {},
}

0 个答案:

没有答案