首页 > 解决方案 > 这在 GrqphQL 预期类型 '[OrderCreationNotificationEnum!] 中是什么意思

问题描述

我有一项服务提供给我使用的 api,他们正在使用 GraphQL。

除了本节之外,其他一切似乎都运行良好。

我正在使用以下查询来创建订单,除了在其中添加通知外,它工作正常

我收到此错误 InputObject 'OrderCreateMutationInput' 上的参数 'notifications' 的值无效({type: {OrderCreationNotificationEnum: {email: true}}})。预期类型“[OrderCreationNotificationEnum!]”

mutation{
orderCreate(input: {
order: {
  externalIds:[
    {key: "VRPOrderId", value: "abc131"}
  ]
  firstName: "John"
  surname: "Doe"
  phone: "0405123456"
  billingFirstName: "John"
  billingSurname: "Doe"
  
  billingEmailAddress: "john@email.com"
  address: {
    address: "1 Bourke Street"
      city: "Melbourne"
      country: {
        code: "AU"
      }
      postcode: "3000"
      state: {
        short: "VIC"
      }
  }
  billingAddress:{
    address: "1 Bourke Street"
      city: "Melbourne"
      country: {
        code: "AU"
      }
      postcode: "3000"
      state: {
        short: "VIC"
      }
  }
  termsAndConditionsAccepted: true
  
}
lineItems: [
  {             
    variantId: "VmFyaWFudC00NzMz"
    quantity: 1
    totalCents: 22500
    postageCents: 1000
    
  },
  {             
    variantId: "VmFyaWFudC00NzYy"
    quantity: 1
    totalCents: 22500
    postageCents: 500
    
  }
]
notifications:
{
    type: {
        OrderCreationNotificationEnum: {
            email: true
        }
    } 
}

})
{
order{
  id
  invoices{
    edges{
      node{
        id
        lineItems{
          id
          quantity
        } 
      }  
    }
  }
}
 status
}
}

我正在努力让通知正常工作。我也在为说明添加链接。请帮忙。

链接到 api 文档

标签: apigraphql

解决方案


InputObject 'OrderCreateMutationInput'上的参数 'notifications'是一个Enum

enum OrderCreationNotificationEnum {
    # Notify the order information via Email
    EMAIL
    # Notify the order information via SMS
    SMS
}

对于通知,您应该指定一个枚举值数组,如下所示:

notifications: [EMAIL, SMS]

推荐阅读