realm - 如何使用 GraphQL 创建/改变一行,其中一个字段是 Realm 中的引用
问题描述
我在 Realm 中创建了以下(测试)集合:
RoundType(集合)
uuid (string)
name (string)
RoundType 中的数据(1 行)
uuid: 234dfg345dfg345 name: Fred Flintstone
测试突变(集合)
uuid (string)
roundType (RoundType)
TestMutate 中的数据:还没有
我想在 TestMutate 中创建一个新行,其中 TestMutate 中的“roundType”字段是对现有RoundType 行的引用。
我尝试了以下方法,希望 GraphQL 知道 roundType 存在,但显然这是不对的。
mutation {
result: addTestMutate(input: {uuid: "abc123", roundType: {id: "234dfg345dfg345"}}) {
uuid
}
}
GraphQL 中实现此目的的正确语法是什么?
解决方案
很酷,我明白了。只需使用**update**TestMutate(..)
而不是addTestMutate
这样:
mutation {
updateTestMutate(input: {uuid: "abc123", roundType: {id: "234dfg345dfg345"}}) {
uuid
}
}
推荐阅读
- c++ - 如何强制 SFINAE 选择结构的第二种定义?
- ruby-on-rails - 在父应用模型中注入 gem 的前置过滤器
- macports - 来自 MacPorts 的 Gnuradio Companion 3.8.2 未在 Catalina 中启动石英
- r - 如何在 purrr:map 函数中循环 lm 函数参数
- sql - 选择最近的时间戳行并从具有 Variant DataType 的列中获取值
- javascript - 使用先前存储在数据库中的凭据执行发送电子邮件的 API 端点。(使用 Gmail REST API)
- list - 如何找到列表中的字符串是另一个列表中另一个字符串的子字符串的次数?
- html - 如何将 4 个元素 2 x 2 弯曲包装
- flutter - 从字段中检索 Firestore 自动生成的文档 ID
- dialogflow-es - 为什么dialogflow不能识别CNY?