GET location_id of new location created during product_create

Hi,

I’m using the below mutation to create new sku, and assigning it a new (not already existing) location. So far it was working well.
I just added the ‘location_id’ to the query, but now it fails as I’m surely doing something wrong. Could you pls help me understand how to change it such that the reply contains the location_id field?

	  product_create(
		data: {
		  sku: "XXXX"
		  name: "XXXX"
		  price: "0.00"
		  customer_account_id: "XXXX"
		  barcode: "XXXX"
		  product_note: "XXXX"
		  warehouse_products: {
			warehouse_id: "XXXX"
			on_hand: "XXXX"
			inventory_bin: "XXXX"
			reserve_inventory: 0
			replenishment_level: 1
			reorder_level: 1
			reorder_amount: 1
			custom: false
		  }
		})
		{
		request_id
		complexity
		product {
		  id
		  legacy_id
		  sku
		  name
		  price
		  account_id
		  barcode
		  warehouse_products {
			warehouse_id
			legacy_id
			on_hand
			inventory_bin
			locations {
				location_id
			}
		  }
		}
	  }

Thanks so much!
Raj

Hi @Raj! You were missing the edge in the location, the mutations should look like this:

mutation {
  product_create(
    data: {
      sku: "XXXX"
      name: "XXXX"
      price: "0.00"
      customer_account_id: "XXXX"
      barcode: "XXXX"
      product_note: "XXXX"
      warehouse_products: {
        warehouse_id: "XXXX"
        on_hand: 1
        inventory_bin: "XXXX"
        reserve_inventory: 0
        replenishment_level: 1
        reorder_level: 1
        reorder_amount: 1
        custom: false
      }
    }
  ) {
    request_id
    complexity
    product {
      id
      legacy_id
      sku
      name
      account_id
      barcode
      warehouse_products {
        warehouse_id
        legacy_id
        on_hand
        inventory_bin
        locations {
          edges {
            node {
              location_id
              created_at
            }
          }
        }
      }
    }
  }
}

Have a nice day!

1 Like

THANK YOU @tomasfd ! It worked perfectly!

1 Like