首页 > 解决方案 > 长生不老药苦艾酒 input_object

问题描述

为什么 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.",

标签: elixirabsinthe

解决方案


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

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

推荐阅读