我正在使用postsConnection无限滚动查询。它包含诸如 之类的变量after。进行赞成突变后,我想refetchQueries......像这样
const upvote = await client.mutate({
mutation: UPVOTE_MUTATION,
variables: {
postId: this.props.post.id
},
refetchQueries: [
{ query: POST_AUTHOR_QUERY }
]
})
Run Code Online (Sandbox Code Playgroud)
上面的代码给出错误,因为POST_AUTHOR_QUERY接受很少的变量。这是该查询
export const POST_AUTHOR_QUERY = gql`
query POST_AUTHOR_QUERY($authorUsername: String! $orderBy: PostOrderByInput $after: String){
postsAuthorConnection(authorUsername: $authorUsername orderBy: $orderBy after: $after) {
....
}
}
Run Code Online (Sandbox Code Playgroud)
我不想手动添加变量。变量已经存储在缓存中。使用时如何重复使用它们refetchQueries???
以下是我读过的有关此问题的一些资源