Open Vacune opened 5 months ago
I'm testing GraphQL calls, and the following example from the documentation:
`<?php // Mutation test $graphQL = <<<Query mutation ($input: CustomerInput!) { customerCreate(input: $input) { customer { id displayName } userErrors { field message } } } Query;
$variables = [ "input" => [ "firstName" => "Greg", "lastName" => "Variables", "email" => "gregvariables@teleworm.us" ] ] $shopify->GraphQL->post($graphQL, null, null, $variables); ?>`
it returns the error:
PHP Fatal error: Uncaught PHPShopify\\Exception\\ApiException: message - syntax error, unexpected COLON (":"), expecting VAR_SIGN at [1, 11], locations - line - 1, column - 11 in /var/www/html/test-app/vendor/phpclassic/php-shopify/lib/ShopifyResource.php:540\nStack trace:\n#0 /var/www/html/test-app/vendor/phpclassic/php-shopify/lib/GraphQL.php(49): PHPShopify\\ShopifyResource->processResponse()\n#1 /var/www/html/test-app/installed.php(86): PHPShopify\\GraphQL->post()\n#2 {main}\n thrown in /var/www/html/test-app/vendor/phpclassic/php-shopify/lib/ShopifyResource.php on line 540, referer: https://admin.shopify.com/
Where is the problem?
Thanks for your cooperation
I have formed the query like this and it works: $graphQL = 'mutation ($input: CustomerInput!) { customerCreate(input: $input) { customer { id displayName } userErrors { field message } } }';
$graphQL = 'mutation ($input: CustomerInput!) { customerCreate(input: $input) { customer { id displayName } userErrors { field message } } }';
I'm testing GraphQL calls, and the following example from the documentation:
`<?php // Mutation test $graphQL = <<<Query mutation ($input: CustomerInput!) { customerCreate(input: $input) { customer { id displayName } userErrors { field message } } } Query;
$variables = [ "input" => [ "firstName" => "Greg", "lastName" => "Variables", "email" => "gregvariables@teleworm.us" ] ] $shopify->GraphQL->post($graphQL, null, null, $variables); ?>`
it returns the error:
PHP Fatal error: Uncaught PHPShopify\\Exception\\ApiException: message - syntax error, unexpected COLON (":"), expecting VAR_SIGN at [1, 11], locations - line - 1, column - 11 in /var/www/html/test-app/vendor/phpclassic/php-shopify/lib/ShopifyResource.php:540\nStack trace:\n#0 /var/www/html/test-app/vendor/phpclassic/php-shopify/lib/GraphQL.php(49): PHPShopify\\ShopifyResource->processResponse()\n#1 /var/www/html/test-app/installed.php(86): PHPShopify\\GraphQL->post()\n#2 {main}\n thrown in /var/www/html/test-app/vendor/phpclassic/php-shopify/lib/ShopifyResource.php on line 540, referer: https://admin.shopify.com/
Where is the problem?
Thanks for your cooperation