在 GraphQL 中创建另一个对象时如何引用一个对象?
我一直在尝试构建一个应用程序,为了简洁起见,假设我只有两种类型的对象,具有以下字段:
- User: user_uid, name, Settings(reference)
- Settings: settings_uid, some_settings_json
到目前为止,我已经尝试创建首先Settings对象,然后将准备好的Settings对象链接到正在创建的User对象。
创建设置对象:
mutation createSettings {
createSettings(data: {some_settings_json: "{"some_key": "some_value"}" }) {
settings_uid
}
}
创建用户对象:
mutation createUser {
createUser(data: {name: "some_user", settings: <SETTINGS_OBJECT>) {
user_uid
}
}
虽然我已经检查过文档、教程、网络;我一直无法弄清楚如何替换
,以便这两个对象能够链接起来。注意:我不想在创建用户时创建设置。为此,教程已经提供了一个示例。
任何帮助将不胜感激。
I've been trying to build an app and for brevity, assuming that I only have two types of objects with the following fields:
- User: user_uid, name, Settings(reference)
- Settings: settings_uid, some_settings_json
So far, I've tried creating Settings object first then linking the ready Settings object to the User object getting created.
Creating the settings object:
mutation createSettings {
createSettings(data: {some_settings_json: "{"some_key": "some_value"}" }) {
settings_uid
}
}
Creating the User object:
mutation createUser {
createUser(data: {name: "some_user", settings: <SETTINGS_OBJECT>) {
user_uid
}
}
Although I've checked documentations, tutorials, web; I haven't been able to figure out how to replace <SETTINGS_OBJECT>
, so that these two objects would get linked. Note: I don't want to create settings while user is getting created. For that, a tutorial already provides an example.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了。该链接是通过
connect
关键字提供的。I found it. The link is provided via
connect
keyword.