Migrating from Admin Rest Api to Graphql

Migrating from Admin Rest Api to Graphql

Yas4131
Visitor
1 0 0

I want to remove a customer from an order using GraphQL. Currently, I'm using the Admin REST API for this:

const { admin, session } = await authenticate.admin(request);

const order = new admin.rest.resources.Order({ session });

order.id = 450789469;
order.customer = null;
await order.save({ update: true });

This works fine using the REST API, but I can't find the equivalent way to do this with GraphQL. Specifically, I tried the following mutation suggested by the Shopify docs assistant AI:

mutation UpdateOrderCustomer {
  orderUpdate(input: { id: "id", customer: null }) {
    order {
      id
      customer {
        id
      }
    }
    userErrors {
      field
      message
    }
  }
}

However, this doesn't work because the customer parameter is not valid for the orderUpdate mutation.

How can I achieve this in GraphQL?

Replies 0 (0)