We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

GraphQL DraftCreateOrder : Expected value to not be null

GraphQL DraftCreateOrder : Expected value to not be null

rkmsoftware
Shopify Partner
22 1 6

I am getting errors while creating draft orders using Graphql API. The same code is working fine on Graphql Explorer the code is attached below.

 

API Code:

const draftvar = {
		"input": {
			"lineItems": [
				{
					"variantId": "gid://shopify/ProductVariant/44317251829918",
					"quantity": 1
				}
			],
			"note": "",
			"email": "johndoe@testdomain.com",
			"tags": [
				"Offline APP"
			],
			"shippingAddress": {
				"address1": "1 Test Road\r\n",
				"city": "Rugby\r\n",
				"countryCode": "GB",
				"zip": "CV22 7RS"
			},
			"billingAddress": {
				"address1": "1 Test Road\r\n",
				"city": "Rugby\r\n",
				"countryCode": "GB",
				"zip": "CV22 7RS"
			},
			"appliedDiscount": {
				"description": "APP",
				"value": 58.33,
				"valueType": "FIXED_AMOUNT",
				"title": "APP"
			},
			"customAttributes": []
		}
	
}
 const responseDraft = await admin.graphql(queryDraft,{draftvar});
 const draftOrder =  await responseDraft.json();

 

Mutation:

 

const queryDraft = `#graphql 
          mutation draftOrderCreate($input: DraftOrderInput!) {
            draftOrderCreate(input: $input) {
              draftOrder {
                id
              }
              userErrors{
                field
                message
              }
            }
          }`;

 

Error: 

 

"graphQLErrors": [
          {
            "message": "Variable $input of type DraftOrderInput! was provided invalid value",
            "locations": [
              {
                "line": 2,
                "column": 37
              }
            ],
            "extensions": {
              "value": null,
              "problems": [
                {
                  "path": [],
                  "explanation": "Expected value to not be null"
                }
              ]
            }
          }
        ],

Please share your suggestions. Will Appricated 😞

Fullstack Developer
Replies 0 (0)