nested object in graphcool

∥☆過路亽.° 提交于 2019-12-11 17:35:08

问题


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?


回答1:


For nested structure you need to define one for type variable like below

type User @model {
   id: ID! @isUnique
   position: Position
}
type Position {
  lat: Int
  lng: Int 
}


来源:https://stackoverflow.com/questions/50784435/nested-object-in-graphcool

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!