Field 'checkoutLineItemsAdd' doesn't exist on type 'Mutation'

hoangbien
Visitor
3 0 0

I am researching to develop an app on shopify. I've used "mutation"

And get the return result: 'Field \'checkoutLineItemsAdd\' doesn\'t exist on type \'Mutation\''
Would you please tell me why not? I am using https://github.com/osiset/laravel-shopify to call the api.
Thank you!
Here query:
$options = new Osiset\BasicShopifyAPI\Options();
$options->setType(true); // Makes it private
$options->setVersion('2021-04');
$options->setApiKey(env('SHOPIFY_API_KEY'));
$options->setApiPassword(env('SHOPIFY_API_PASSWORD'));

$api = new Osiset\BasicShopifyAPI\BasicShopifyAPI($options);
$api->setSession(new Osiset\BasicShopifyAPI\Session(env('SHOPIFY_MYSHOPIFY_DOMAIN'),env('SHOPIFY_API_PASSWORD')));
Log::info($result = $api->graph('mutation {
checkoutLineItemsAdd(lineItems: [{ variantId: "39974961316002", quantity: 5 }], checkoutId: "c324e358f7290a55a83d797a294f382b",
) {
checkout {
id
lineItems(first:2) {
edges {
node {
id
title
quantity
}
}
}
}
}
}'));
Result error:
[2021-05-26 08:21:42] local.INFO: array (
'errors' =>
array (
0 =>
array (
'message' => 'Field \'checkoutLineItemsAdd\' doesn\'t exist on type \'Mutation\'',
'locations' =>
array (
0 =>
array (
'line' => 3,
'column' => 3,
),
),
'path' =>
array (
0 => 'mutation',
1 => 'checkoutLineItemsAdd',
),
'extensions' =>
array (
'code' => 'undefinedField',
'typeName' => 'Mutation',
'fieldName' => 'checkoutLineItemsAdd',
),
),
),
'response' =>
GuzzleHttp\Psr7\Response::__set_state(array(
'reasonPhrase' => 'OK',
'statusCode' => 200,
'headers' =>
array (
'Date' =>
array (
0 => 'Wed, 26 May 2021 08:21:43 GMT',
),
'Content-Type' =>
array (
0 => 'application/json; charset=utf-8',
),
'Transfer-Encoding' =>
array (
0 => 'chunked',
),
'Connection' =>
array (
0 => 'keep-alive',
),
'X-Sorting-Hat-PodId' =>
array (
0 => '161',
),
'X-Sorting-Hat-ShopId' =>
array (
0 => '55409672354',
),
'Vary' =>
array (
0 => 'Accept-Encoding',
),
'Referrer-Policy' =>
array (
0 => 'origin-when-cross-origin',
),
'X-Frame-Options' =>
array (
0 => 'DENY',
),
'X-ShopId' =>
array (
0 => '55409672354',
),
'X-ShardId' =>
array (
0 => '161',
),
'X-Stats-UserId' =>
array (
0 => '',
),
'X-Stats-ApiClientId' =>
array (
0 => '5256811',
),
'X-Stats-ApiPermissionId' =>
array (
0 => '318958862498',
),
'X-Shopify-API-Version' =>
array (
0 => '2021-04',
),
'Content-Language' =>
array (
0 => 'en',
),
'Strict-Transport-Security' =>
array (
0 => 'max-age=7889238',
),
'X-Shopify-Stage' =>
array (
0 => 'production',
),
'Content-Security-Policy' =>
array (
0 => 'default-src \'self\' data: blob: \'unsafe-inline\' \'unsafe-eval\' https://* shopify-pos://*; block-all-mixed-content; child-src \'self\' https://* shopify-pos://*; connect-src \'self\' wss://* https://*; frame-ancestors \'none\'; img-src \'self\' data: blob: https:; script-src https://cdn.shopify.com https://cdn.shopifycdn.net https://checkout.shopifycs.com https://api.stripe.com https://mpsnare.iesnare.com https://appcenter.intuit.com https://www.paypal.com https://js.braintreegateway.com https://c.paypal.com https://maps.googleapis.com https://www.google-analytics.com https://v.shopify.com https://widget.intercom.io https://js.intercomcdn.com \'self\' \'unsafe-inline\' \'unsafe-eval\'; upgrade-insecure-requests; report-uri /csp-report?source%5Baction%5D=query&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fgraphql&source%5Bsection%5D=admin_api&source%5Buuid%5D=0c0e61cf-86f6-47d0-a49d-1e8b1d927d33',
),
'X-Content-Type-Options' =>
array (
0 => 'nosniff',
),
'X-Download-Options' =>
array (
0 => 'noopen',
),
'X-Permitted-Cross-Domain-Policies' =>
array (
0 => 'none',
),
'X-XSS-Protection' =>
array (
0 => '1; mode=block; report=/xss-report?source%5Baction%5D=query&source%5Bapp%5D=Shopify&source%5Bcontroller%5D=admin%2Fgraphql&source%5Bsection%5D=admin_api&source%5Buuid%5D=0c0e61cf-86f6-47d0-a49d-1e8b1d927d33',
),
'X-Dc' =>
array (
0 => 'gcp-asia-east2,gcp-us-east1,gcp-us-east1',
),
'NEL' =>
array (
0 => '{"report_to":"network-errors","max_age":2592000,"success_fraction":0.0001}',
1 => '{"report_to":"network-errors","max_age":2592000,"success_fraction":0.0001}',
),
'Report-To' =>
array (
0 => '{"group":"network-errors","max_age":2592000,"endpoints":[{"url":"https://monorail-edge.shopifysvc.com/v1/reports/nel/20190325/shopify"}]}',
1 => '{"group":"network-errors","max_age":2592000,"endpoints":[{"url":"https://monorail-edge.shopifysvc.com/v1/reports/nel/20190325/shopify"}]}',
),
'X-Request-ID' =>
array (
0 => '0c0e61cf-86f6-47d0-a49d-1e8b1d927d33',
),
'CF-Cache-Status' =>
array (
0 => 'DYNAMIC',
),
'cf-request-id' =>
array (
0 => '0a495cfaa10000125279a9b000000001',
),
'Expect-CT' =>
array (
0 => 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"',
),
'Server' =>
array (
0 => 'cloudflare',
),
'CF-RAY' =>
array (
0 => '65559770f84d1252-HKG',
),
'alt-svc' =>
array (
0 => 'h3-27=":443"; ma=86400, h3-28=":443"; ma=86400, h3-29=":443"; ma=86400',
),
),
'headerNames' =>
array (
'date' => 'Date',
'content-type' => 'Content-Type',
'transfer-encoding' => 'Transfer-Encoding',
'connection' => 'Connection',
'x-sorting-hat-podid' => 'X-Sorting-Hat-PodId',
'x-sorting-hat-shopid' => 'X-Sorting-Hat-ShopId',
'vary' => 'Vary',
'referrer-policy' => 'Referrer-Policy',
'x-frame-options' => 'X-Frame-Options',
'x-shopid' => 'X-ShopId',
'x-shardid' => 'X-ShardId',
'x-stats-userid' => 'X-Stats-UserId',
'x-stats-apiclientid' => 'X-Stats-ApiClientId',
'x-stats-apipermissionid' => 'X-Stats-ApiPermissionId',
'x-shopify-api-version' => 'X-Shopify-API-Version',
'content-language' => 'Content-Language',
'strict-transport-security' => 'Strict-Transport-Security',
'x-shopify-stage' => 'X-Shopify-Stage',
'content-security-policy' => 'Content-Security-Policy',
'x-content-type-options' => 'X-Content-Type-Options',
'x-download-options' => 'X-Download-Options',
'x-permitted-cross-domain-policies' => 'X-Permitted-Cross-Domain-Policies',
'x-xss-protection' => 'X-XSS-Protection',
'x-dc' => 'X-Dc',
'nel' => 'NEL',
'report-to' => 'Report-To',
'x-request-id' => 'X-Request-ID',
'cf-cache-status' => 'CF-Cache-Status',
'cf-request-id' => 'cf-request-id',
'expect-ct' => 'Expect-CT',
'server' => 'Server',
'cf-ray' => 'CF-RAY',
'alt-svc' => 'alt-svc',
),
'protocol' => '1.1',
'stream' =>
GuzzleHttp\Psr7\Stream::__set_state(array(
'stream' => NULL,
'size' => NULL,
'seekable' => true,
'readable' => true,
'writable' => true,
'uri' => 'php://temp',
'customMetadata' =>
array (
),
)),
)),
'status' => 200,
'body' =>
Osiset\BasicShopifyAPI\ResponseAccess::__set_state(array(
'container' =>
array (
'errors' =>
array (
0 =>
array (
'message' => 'Field \'checkoutLineItemsAdd\' doesn\'t exist on type \'Mutation\'',
'locations' =>
array (
0 =>
array (
'line' => 3,
'column' => 3,
),
),
'path' =>
array (
0 => 'mutation',
1 => 'checkoutLineItemsAdd',
),
'extensions' =>
array (
'code' => 'undefinedField',
'typeName' => 'Mutation',
'fieldName' => 'checkoutLineItemsAdd',
),
),
),
),
'position' => 0,
)),
'timestamps' =>
array (
0 => 1622017302091361.0,
),
)

Replies 3 (3)

hoangbien
Visitor
3 0 0

@hassain Can you help me with this problem? Thank you.

c10s
Shopify Partner
67 12 25

I think you may be trying to run this mutation with the Admin API, when this checkoutLineItemsAdd is only available on the Storefront API.

hoangbien
Visitor
3 0 0

Thank @c10s for support.  I have solved this problem.

But I have another problem that I don't know how to change product price from webhook before switching to checkout (For example, I want to add a free gift cart product to checkout but with the condition that the price of this product must be 0. Meanwhile I can't add a product from admin with zero price.). Can you give me any advice on this? I really need help with this