代码之家  ›  专栏  ›  技术社区  ›  karolis2017

为什么这不影响查询?

  •  0
  • karolis2017  · 技术社区  · 8 年前

    我想在注册完成后重新设置查询:

    async componentDidMount() {
        const res = await this.props
            .signup({
                variables: { shortLivedToken: this.props.match.params.token },
                refetchQueries: [{ query: ME_QUERY }]
            })
            .catch(e => {
                this.setState({ error: e.message, loader: false })
            })
    

    一切都很好,但我必须做整个页面刷新,因为 ME_QUERY 未重新蚀刻。

    以下是查询:

    export const ME_QUERY = gql`
      query ME_QUERY {
        me{
          id
          email
          items{
            id
            title
          }
          cart {
          quantity
          id
          item {
            title
            description
            price
            id
            image
            }
          }
        }
      }
    `
    
    0 回复  |  直到 8 年前