graphcool中的嵌套对象 [英] nested object in graphcool

查看:47
本文介绍了graphcool中的嵌套对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的模型:

  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 
    }
}

但是我从Graphcool中收到一个错误,

but I get a error from Graphcool,

{", expected IgnoredNoComment, ImplementsInterfaces or Directives (line 4, column 11):
 type User @model {
      ^ 

为什么?我不能传递嵌套对象吗?通过这种方式,我可以简单地通过lat和lng传递对象来更新变异.怎么了?

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?

推荐答案

对于嵌套结构,您需要为以下类型的变量定义一个

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 
}

这篇关于graphcool中的嵌套对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆