graphql - nested object in graphcool
问题描述
I have a model like this:
type User @model {
id: ID! @isUnique
}
Now I want to add a nested object:
type User @model {
id: ID! @isUnique
position: {
lat: Int
lng: Int
}
}
but I get a error from Graphcool,
{", expected IgnoredNoComment, ImplementsInterfaces or Directives (line 4, column 11):
type User @model {
^
Why? can't I pass a nested object? In this way I can update the mutation simply passing the object with lat and lng. What is wrong with this?
解决方案
对于嵌套结构,您需要为类型变量定义一个,如下所示
type User @model {
id: ID! @isUnique
position: Position
}
type Position {
lat: Int
lng: Int
}
推荐阅读
- php - php file_get_contents 未捕获某些 cookie 组
- django - ModelForm required=True 未按预期运行
- c# - 如何在后面的代码中应用 materialDesign:ColorZoneAssist.Mode="Accent"
- amazon-web-services - KUBERNETES AWSElasticBlockStore PersistentVolume:NoCredentialProviders:链中没有有效的提供者
- python - 如何在记录未知长度的数据时修复错误?
- python - 用python编写的def函数中的加密代码
- python - python-'Status'对象没有属性'lower'
- java - 在混合模式下使用 URI(Windows 和 Linux)
- vba - Excel-vba:使用用户定义函数 (UDF) 获取单元格公式中的选定单元格
- android - 退还用户钱