知识卡片
字段参数用括号传入
GraphQL 字段参数写在字段名后的括号中,按 名称: 值 传入,例如 ingredient(id: "asdf")。模式声明为非空的参数不可省略;无参数字段省略括号,空括号会形成语法错误。调用前应对照模式确认参数名和类型。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
原书出处
参考来源
- 位置:《Microservice APIs》第 9 章《Consuming GraphQL APIs》(源文件:_epub-src/OEBPS/Text/09.htm)
- 结论依据:原文展示 ingredient 的 id 参数调用,并对比缺失参数与空括号的错误。
- 原始内容:we include the query parameters as key-value pairs separated by a colon within parentheses. Listing 9.3 Running a query with a required parameter { ingredient(id: "asdf") { ① name } }