Using API fields with arguments in Shopify Flow to create variables

Some variables require additional parameters in order to function correctly in a Shopify Flow workflow. These parameters are arguments that must have values declared by you before the variable is considered complete and useable by the workflow.

For example, the product.inCollection field determines whether or not a product is in a specified collection and returns a Boolean true or false result. However, the collection's id argument must be included for this field, because otherwise the variable won't know what specific collection to check for. To use the field correctly, you must include the argument as part of the field. For example, querying product.inCollection(id: "gid://shopify/Collection/123456") so that Flow can determine whether or not the product is in the collection with the ID of 123456, and then return true or false as expected. When creating variables in Shopify Flow, you don't need to search for values such as product or collection IDs. Flow provides a resource picker to select the value that you want, and the ID is filled in automatically.

To simplify the experience of querying fields with arguments, you can assign a new variable name to the variable that you create from the field and argument in Shopify Flow. For example, if the name of the collection with the ID of 123456 is Summer Bestsellers, then you could assign the inCollection(id: "gid://shopify/Collection/123456") variable a simpler name of inSummerBestsellers. Then, in all subsequent steps of the workflow, you can simply use the variable product.inSummerBestsellers.

Because arguments differ depending on what values are assigned to them, you can create multiple new variables from a single field requiring arguments. For example, you could create 3 unique variables from just the product.inCollection field:

  • product.inCollection(id: "gid://shopify/Collection/123456") could be product.inSummerBestsellers.
  • product.inCollection(id: "gid://shopify/Collection/654321") could be product.inSwimwear.
  • product.inCollection(id: "gid://shopify/Collection/112233") could be product.inBeachAccessories.

Supported GraphQL Admin API fields in Shopify Flow

Shopify Flow supports the following fields in the GraphQL Admin API with required arguments:

Unsupported GraphQL Admin API fields in Shopify Flow

Shopify Flow doesn't support the following fields:

To use data from these unsupported fields in your workflow, you must use a Send HTTP request action.

Creating a variable from a field with an argument

You can create a variable in Shopify Flow for any supported field that requires an argument. You only need to create the variable one time in a single workflow, as the variable remains available as an option in all subsequent steps of the workflow.

The variable that you create isn't shared with any other workflows, so to use it in another workflow, you must add it again in that other workflow.

Steps:

  1. In a Shopify Flow workflow, click Add a variable in an action or condition.
  2. Select a field that requires an argument. These fields display a + button. Then, click + Create variable.
  3. In the Create variable dialog, do the following steps:
    1. Based on the field that you selected, set a value for the required argument.
    2. Optional: In the New variable name field, customize what you want the new variable to be called. This name applies only to the current workflow.
    3. Click Add to refresh the variable selection panel.

After adding the new variable to a workflow, the variable remains available as a field option and you can quickly reference it in subsequent steps. When choosing to Add a variable, it displays nested beneath the original field option in the list of fields.

Creating a variable from a metafield in Shopify Flow

Metafields are a type of variable with fields that require arguments. Getting metafield data in a Shopify Flow workflow differs slightly from getting standard field data in other variables because you create and define the metafield's namespace and key field values, so they're always unique to your store.

For example, the product.inCollection field always requires the id argument, regardless of which store you're working in. However, because you set the namespace and key for every metafield that you create in your store, the required arguments are custom. So, a variable for a product metafield that captures the care instructions for a summer clothing product might be product.careGuideSummer.value, or a variable for a product metafield that records the ID of the age group the product is for might be product.ageGroup.value_item.taxonomyReference.id. The field names and arguments are determined entirely by you.

Learn more about metafields in Shopify Flow.