我有两个查询
const getFullUser = gql`
query getFullUser {
...getUserId
...getUserFirstName
...getUserLastName
...getUserFullName
}
${getUserId}
${getUserFirstName}
${getUserLastName}
${getUserFullName}
`;
const getPartialUser = gql`
query getPartialUser {
...getUserId
...getUserFirstName
...getUserLastName
}
${getUserId}
${getUserFirstName}
${getUserLastName}
`;
和1个突变
const SET_USER = gql`
mutation setUser($firstname: String!, $lastname: String!) {
user(firstname: $firstname, lastname: $lastname) {
id
name {
id
first
last
}
}
}
`;
执行变异时,仅依赖getPartialUser
的组件会被重新渲染。有什么我可以强迫getFullUser
组件重新呈现/重新查询的吗?问题似乎是从null到部分对象后,并非所有数据都可用,因此它拒绝更新。强制重新渲染/重新查询的选项有哪些?
理想情况下,我正在寻找一种不涉及将字段直接(或通过片段)添加到突变的方法,因为这看起来很脆弱。
请参阅详细的Github存储库https://github.com/nagolyhprum/apollo-incomplete-mutation。