Graphql API orderCreate toUpsert a customer don't work

Solved

Graphql API orderCreate toUpsert a customer don't work

MartinJackS
Shopify Partner
5 1 0

Hi,

I would like to use the OrderCreateCustomerInput when using the mutation orderCreate of the graphQL api.
For example, when using the example shown in the documentation:

const client = new shopify.clients.Graphql({session});
const data = await client.query({
  data: {
    "query": `mutation OrderCreate($order: OrderCreateOrderInput!, $options: OrderCreateOptionsInput) {
      orderCreate(order: $order, options: $options) {
        userErrors {
          field
          message
        }
        order {
          id
          displayFinancialStatus
          customer {
            email
            firstName
            lastName
          }
        }
      }
    }`,
    "variables": {
      "order": {
        "lineItems": [
          {
            "variantId": "gid://shopify/ProductVariant/43729076",
            "quantity": 1
          }
        ],
        "customer": {
          "toUpsert": {
            "email": "foo.bar@shopify.com",
            "firstName": "Foo",
            "lastName": "Bar"
          }
        },
        "financialStatus": "PAID"
      }
    },
  },
});

 

 an error is thrown:

Error: Variable $order of type OrderCreateOrderInput! was provided invalid value for customer (Field is not defined on OrderCreateOrderInput)

Can you provide more details about how to use this fields?

Best,

Accepted Solution (1)

MartinJackS
Shopify Partner
5 1 0

This is an accepted solution.

Solved.
I wasn't using the last API version

View solution in original post

Reply 1 (1)

MartinJackS
Shopify Partner
5 1 0

This is an accepted solution.

Solved.
I wasn't using the last API version