【问题标题】:Elixir Absinthe input_object长生不老药苦艾酒 input_object
【发布时间】:2018-12-25 05:46:50
【问题描述】:

为什么 Elixir Absinthe 中的 input_object 不起作用?

喜欢

   input_object :vehicle_detail do
    field :registrationNo, :string
    field :imageUrl, :string
   end

  mutation do
    field :create_user, type: :user do
        arg :vehicle_details, :vehicle_detail

        resolve &Resolver.create_employee/2
    end
  end

我尝试过,但它为以下有效负载抛出错误

mutation() {
  employee: createEmployee(vehicleDetails: {
      registrationNo: "AP03EY0096",
      imageUrl: "http://sample.example.com"
  }) {
    id
  }
}

错误

In field \"vehicleDetails\": Expected type \"VehicleDetail\", found $vehicleDetails.\nIn field \"imageUrl\": Unknown field.\nIn field \"registrationNo\": Unknown field.",

【问题讨论】:

  • intput_object 中有错字,是故意的吗?
  • 得到错误的原因。 intput_object - :vehicle_detail 具有驼峰式字段名称。换成蛇皮后,它起作用了。
  • @JonasDellinger 感谢更新了问题,这只是一个错字,但实际代码没有错字。

标签: elixir absinthe


【解决方案1】:

请尝试在蛇形案例中使用原子来定义输入对象:

  input_object :vehicle_detail do
    field(:registration_no, :string)
    field(:image_url, :string)
  end

【讨论】:

    猜你喜欢
    • 2018-06-09
    • 2021-10-14
    • 2018-12-03
    • 2021-07-08
    • 1970-01-01
    • 2016-02-01
    • 2010-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多