Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

GraphQL mutation example returns syntax error unexpected COLON(":") #326

Open
Vacune opened this issue Jun 15, 2024 · 1 comment
Open

GraphQL mutation example returns syntax error unexpected COLON(":") #326

Vacune opened this issue Jun 15, 2024 · 1 comment

Comments

@Vacune
Copy link

Vacune commented Jun 15, 2024

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

@Vacune
Copy link
Author

Vacune commented Jun 15, 2024

I have formed the query like this and it works:
$graphQL = 'mutation ($input: CustomerInput!) { customerCreate(input: $input) { customer { id displayName } userErrors { field message } } }';

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant