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.