Updating a single product in shopify app using Laravel and Graph QL

Updating a single product in shopify app using Laravel and Graph QL


0

Im using Laravel to create a Shopify app. I have a mutation to create a product in shopify which works fine…

private const CREATE_PRODUCTS_MUTATION = <<<'QUERY'
mutation populateProduct($input: ProductInput!) {
productCreate(input: $input) {
product {
id
}
}
}
QUERY;

$response = $graph->query(
    [
      "query" => self::CREATE_PRODUCTS_MUTATION,
      "variables" => [
        "input" => [
         "title" => 'This is the product title ',
         "descriptionHtml" => "This is the description",
        ]
      ]
    ]

My problem is when I want to update a product (rather than create one)
I have a similar set up…

private const UPDATE_PRODUCTS_MUTATION = <<<'QUERY'
    mutation productUpdate($productId: ID!, $input: ProductInput!) {
        productUpdate(input: $input) {
            product {
                id
            }
        }
    }
    QUERY;

$response = $graph->query(
    [
      "query" => self::UPDATE_PRODUCTS_MUTATION,
      "variables" => [
        "input" => [
         "id" => PRODUCT ID HERE,
         "title" => 'This is the product title ',
         "descriptionHtml" => "This is the description",
        ]
      ]
    ]

This mutation still creates a new product rather updating an existing. Im going round in circles on where Im going wrong but I cant find any information online.


Load 6 more related questions


Show fewer related questions

0



Leave a Reply

Your email address will not be published. Required fields are marked *