May 10, 2023

Use PurchasingEntity, DiscountApplications and other dynamic type fields in Shopify Flow

Union fields are those where a single variable has more than one possible type. There are many examples in the Shopify GraphQL API. For example, purchasingEntity on an order can be either a PurchasingCompany or a Customer.

Interface fields are similar, but the types share a set of fields. For example all of the DiscountApplications types share a “value” object.

With these fields types accessible in Flow, you can build new types or workflows that make use of this data.

For example, you can now check if a Scripts discount was applied to an order. With PurchasingEntity, you can now check which company placed an order.

Because these fields might not always be the type you are expecting, it’s important to check the type in your conditions. For this purpose, you can choose the “typename” field on the corresponding object and then select which type you want to check.