OrderUpdate GraphQL mutation removes the email if not specified

Elrendio
New Member
9 0 0

I'm using a GraphQL client that automatically generates structures based on the GraphQL schema.

This part of the schema (https://shopify.dev/docs/admin-api/graphql/reference/mutation/input-object/orderinput?api[version]=2...

 

        {
          "kind": "INPUT_OBJECT",
          "name": "OrderInput",
          "description": "Specifies the information to be updated on the requested order.",
          "enumValues": null,
          "fields": null,
          "inputFields": [
            {
              "defaultValue": null,
              "description": "The email address associated with the order.",
              "name": "email",
              "type": {
                "kind": "SCALAR",
                "name": "String",
                "ofType": null
              }
            },
            ... and other fields
          ],
          "interfaces": null,
          "possibleTypes": null
        }

 

Generates the following:

 

struct OrderInput {
    email: Option<String>,
    ... and other fields
}

 

 

When the email is unspecified (email is not among the fields I want to update), the GraphQL client serializes this as {"email":null, ...and other fields}.

As it turns out, the current behaviour of Shopify is that when receiving such a request, it will remove the email from the order. That does not seem to be the case for the shipping address (does not do anything and does not trigger an error), and I'm not sure about what it does on customAttributes, metafields and note.

I have three questions:

 - Shouldn't it instead avoid removing the email when receiving null in this update, and remove it only when receiving an empty string ?

 - Would the way I'm currently calling this endpoing also remove customAttributes, metafields and note if they were initially non empty on the order ?

 - What would you suggest to avoid accidentally clearing other fields when calling this endpoint ?

0 Likes