javascript - 如何访问嵌套对象
问题描述
GraphQL 嵌套突变
如何访问已创建的成分键/值?
这是ingredients
查询:
ingredients{
amount
unit
food{
bls
name
kcal
}
}
mutation {
createRecipe(
data: {
title: "ABC"
author: "XYZ"
level: EASY
ingredients: {amount: 250, unit: GRAMM, food: {name: "Flour", bls: "xxx", kcal: 203}
}
}
解析器
Mutation: {
createRecipe: (_, args) => {
const newRecipe = {
title: args.data.title,
author: args.data.author,
level: args.data.level,
ingredients: args.........??????
};
}
}
结果
"data": {
"createRecipe": {
"title": "ABC",
"author": "XYZ",
"level": "EASY",
"ingredients": null,
}
}
我如何访问ingredients' amount, unit
并ingredients food name,bls,kcal
填充 gql 操场上的成分数组?
解决方案
推荐阅读
- wordpress - Wordpress Flatsome 主题(UX Builder)不保存更改
- python - 基于触发器并发运行python脚本
- java - Maven:NDJ4 有后端,错误说没有
- visual-studio - 如何从 VBScript 运行批处理文件作为 Visual Studio 安装程序项目中的自定义操作?
- python - 如何在列表中的命令每次迭代后运行命令?
- sql - SQL Server:获取同一表的日期值之间的实际最小值
- php - jquery和php之间使用GET交互
- python - 如何为 Python 请求有效负载创建批量 JSON?
- python - 如何识别我的 python 脚本运行缓慢的位置
- excel - Excel VBA根据单元格值删除行