graphql - 在 Apollo 客户端缓存中展平对象
问题描述
所以我是阿波罗客户端的新手并尝试连接它所以我想了解如何在缓存中的查询中展平嵌套对象我的代码看起来像 获取所有用户的查询
export const GET_USERS = gql`
query User {
users {
id
username
email
role {
__typename
name
}
}
}
我的索引
const cache = new InMemoryCache({
typePolicies: {
Users: {
},
},
});
我需要的输出就像
[{
id
username
email
roleName
}]
解决方案
推荐阅读
- python - 400 错误请求:浏览器(或代理)发送了此服务器无法理解的请求。KeyError:“名称搜索”
- python - 根据其他列 panda 的值创建新列
- gnuplot - 相对于 Gnuplot 中的行号绘图
- python - 当我更改所需的文本文件时,如何让 tkinter 应用程序更新?
- html - 我如何更改 style.css 的 Href
- node.js - 解密工作使用 PHP (openssl) 而不是使用 javascript (cryptojs)
- api - 得到响应后得到 400,尽管 url 格式正确
- python - 在python中如何检查文件是否已被其他软件打开?(在 Linux 中)
- flutter - Flutter 音频播放器在多个播放事件后停止播放
- ios - 无法找到呈现视图控制器 - 覆盖中的 UIDatePicker