PriceList and assign marketID GRAPHSQL

Topic summary

A developer encountered a sudden error when attempting to create a PriceList and assign a MarketID using Shopify’s GraphQL API (version 2023-01).

Error Details:

  • The mutation returns: “Field ‘contextRule’ doesn’t exist on type ‘PriceList’”
  • Error occurs at line 1, column 150 in the query
  • The code uses a PHP cURL implementation with the priceListCreate mutation

Proposed Solution:
A responder suggests removing contextRule { market { id } } from the query, noting that this field is not available in the PriceList object according to Shopify’s documentation.

Status: The issue appears to stem from attempting to query a non-existent field in the response, though the mutation input includes contextRule with marketId. The discussion remains open pending confirmation whether removing the field from the query selection resolves the error.

Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

Hello

I need to create a PriceList and assign a MarketID but I have an error. It stopped working SUDDENLY.

Can anyone tell me what might be wrong?? Thank you

$ch = curl_init();
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json','X-Shopify-Access-Token:'.$data['api_password']));
        curl_setopt($ch, CURLOPT_URL, 'https://'.$data['api_host'].'/admin/api/2023-01/graphql.json');
        curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
        curl_setopt($ch, CURLOPT_POSTFIELDS ,'{"query": "mutation PriceListCreate($input: PriceListCreateInput!) { priceListCreate(input: $input) { userErrors { field message } priceList { id name currency contextRule { market { id } } parent { adjustment { type value } } } } }","variables": {"input": {"name": "'.$data['currency'].'_'.$data['name'].'","currency": "'.$data['currency'].'","contextRule": {"marketId": "'.$data['marketId'].'"},"parent": {"adjustment": {"type": "PERCENTAGE_DECREASE","value": 0}}}}}');
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
        curl_setopt($ch, CURLOPT_VERBOSE, true);

        $result=curl_exec ($ch);

        curl_close ($ch);
        $array = json_decode($result, true);

Error:

[errors] => Array
        (
            [0] => Array
                (
                    [message] => Field 'contextRule' doesn't exist on type 'PriceList'
                    [locations] => Array
                        (
                            [0] => Array
                                (
                                    [line] => 1
                                    [column] => 150
                                )

                        )

                    [path] => Array
                        (
                            [0] => mutation PriceListCreate
                            [1] => priceListCreate
                            [2] => priceList
                            [3] => contextRule
                        )

                    [extensions] => Array
                        (
                            [code] => undefinedField
                            [typeName] => PriceList
                            [fieldName] => contextRule
                        )

                )

        )

I

Hey @pstanek

Are you able to remove contextRule { market { id } } from the query? This field isn’t available.