Create Checkout

Create Checkout

Fydez
Shopify Partner
8 0 0

this is  Create Checkout mutaion  from doc

mutation checkoutCreate($input: CheckoutCreateInput!) {
         checkoutCreate(input: $input) {
            checkout {
                       # Checkout fields
            }
          checkoutUserErrors {
                   # CheckoutUserError fields
           }
          queueToken
     }
}

whyyyyyyyyyyyyy this error occur ‌‌ 😭

{
    "errors": [
        {
            "message": "CheckoutCreateInput isn't a defined input type (on $input)",
            "locations": [
                {
                    "line": 1,
                    "column": 25
                }
            ],
            "path": [
                "mutation checkoutCreate"
            ],
            "extensions": {
                "code": "variableRequiresValidType",
                "typeName": "CheckoutCreateInput",
                "variableName": "input"
            }
        },
        {
            "message": "Field 'checkoutCreate' doesn't exist on type 'Mutation'",
            "locations": [
                {
                    "line": 3,
                    "column": 15
                }
            ],
            "path": [
                "mutation checkoutCreate",
                "checkoutCreate"
            ],
            "extensions": {
                "code": "undefinedField",
                "typeName": "Mutation",
                "fieldName": "checkoutCreate"
            }
        },
        {
            "message": "Variable $input is declared by checkoutCreate but not used",
            "locations": [
                {
                    "line": 1,
                    "column": 1
                }
            ],
            "path": [
                "mutation Checkout Create"
            ],
            "extensions": {
                "code": "variable Not Used",
                "variable Name": "input"
            }
        }
    ]
}
Replies 8 (8)

ShopifyDevSup
Shopify Staff
1453 238 511

Hey @Fydez , that's a great questions. It's hard to say exactly here without seeing the full details of your request, but based on the errors you've provided, it seems that you may not have provided or required the proper input fields. I would take a look at how you've formatted the variables to ensure it's correct. 

 

This section of the document you linked mentions what's needed: https://shopify.dev/docs/api/storefront/2023-10/mutations/checkoutCreate#returns 

 

Hope that helps!

 

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Fydez
Shopify Partner
8 0 0

my mutation Code is :

mutation checkoutCreate($input: CheckoutCreateInput!) {
              checkoutCreate(input: $input) {
                checkout {
                  id
                }
                checkoutUserErrors {
                      code
                      field
                      message
                }
                queueToken
              }
            }

and my input is:

 

{
    "input": {
        "allowPartialAddresses": true,
        "buyerIdentity": {
            "countryCode": "AU"
        },
        "customAttributes": [
            {
                "key": "",
                "value": ""
            }
        ],
        "email": "Karimy.ehsan@gmail.com",
        "note": "test",
        "presentmentCurrencyCode": "AU",
        "shippingAddress": {
            "address1": "15 Barker Street",
            "address2": "",
            "city": "Forest Hill",
            "company": "",
            "country": "Australia",
            "firstName": "Ehsan",
            "lastName": "karimi",
            "phone": "(08) 9073 4623",
            "province": "Western Australia",
            "zip": "6324"
        },
        "lineItems": [
            {
                "customAttributes": null,
                "quantity": 1,
                "variantId": "gid://shopify/ProductVariant/46850414182711"
            }
        ]
    },
    "queueToken": "1"
}

and response is : 

{
    "errors": [
        {
            "message": "CheckoutCreateInput isn't a defined input type (on $input)",
            "locations": [
                {
                    "line": 1,
                    "column": 25
                }
            ],
            "path": [
                "mutation checkoutCreate"
            ],
            "extensions": {
                "code": "variableRequiresValidType",
                "typeName": "CheckoutCreateInput",
                "variableName": "input"
            }
        },
        {
            "message": "Field 'checkoutCreate' doesn't exist on type 'Mutation'",
            "locations": [
                {
                    "line": 3,
                    "column": 15
                }
            ],
            "path": [
                "mutation checkoutCreate",
                "checkoutCreate"
            ],
            "extensions": {
                "code": "undefinedField",
                "typeName": "Mutation",
                "fieldName": "checkoutCreate"
            }
        },
        {
            "message": "Variable $input is declared by checkoutCreate but not used",
            "locations": [
                {
                    "line": 1,
                    "column": 1
                }
            ],
            "path": [
                "mutation checkoutCreate"
            ],
            "extensions": {
                "code": "variableNotUsed",
                "variableName": "input"
            }
        }
    ]
}

and url is : 
https://fydez.myshopify.com/admin/api/2023-07/graphql.json

Fydez
Shopify Partner
8 0 0

this is mu mutation code for create checkout

mutation checkoutCreate($input: CheckoutCreateInput!) {
              checkoutCreate(input: $input) {
                checkout {
                  id
                }
                checkoutUserErrors {
                      code
                      field
                      message
                }
                queueToken
              }
            }

and this my input variable:

{
    "input": {
        "allowPartialAddresses": false,
        "buyerIdentity": {
            "countryCode": "AU"
        },
        "customAttributes": [
            {
                "key": "",
                "value": ""
            }
        ],
        "email": "Karimy.ehsan@gmail.com",
        "note": "test",
        "presentmentCurrencyCode": "AU",
        "shippingAddress": {
            "address1": "15 Barker Street",
            "address2": "",
            "city": "Forest Hill",
            "company": "",
            "country": "Australia",
            "firstName": "Ehsan",
            "lastName": "karimi",
            "phone": "(08) 9073 4623",
            "province": "Western Australia",
            "zip": "6324"
        },
        "lineItems": [
            {
                "customAttributes": [
                    {
                        "key": "",
                        "value": ""
                    }
                ],
                "quantity": 1,
                "variantId": "gid://shopify/ProductVariant/46850414182711"
            }
        ]
    },
    "queueToken": ""
}

and this is the response:

{
    "errors": [
        {
            "message": "CheckoutCreateInput isn't a defined input type (on $input)",
            "locations": [
                {
                    "line": 1,
                    "column": 25
                }
            ],
            "path": [
                "mutation checkoutCreate"
            ],
            "extensions": {
                "code": "variableRequiresValidType",
                "typeName": "CheckoutCreateInput",
                "variableName": "input"
            }
        },
        {
            "message": "Field 'checkoutCreate' doesn't exist on type 'Mutation'",
            "locations": [
                {
                    "line": 3,
                    "column": 15
                }
            ],
            "path": [
                "mutation checkoutCreate",
                "checkoutCreate"
            ],
            "extensions": {
                "code": "undefinedField",
                "typeName": "Mutation",
                "fieldName": "checkoutCreate"
            }
        },
        {
            "message": "Variable $input is declared by checkoutCreate but not used",
            "locations": [
                {
                    "line": 1,
                    "column": 1
                }
            ],
            "path": [
                "mutation checkoutCreate"
            ],
            "extensions": {
                "code": "variableNotUsed",
                "variableName": "input"
            }
        }
    ]
}

and post url is :
https://fydez.myshopify.com/admin/api/2023-07/graphql.json

Fydez
Shopify Partner
8 0 0

this is my mutation for create checkout:

mutation checkoutCreate($input: CheckoutCreateInput!) {
              checkoutCreate(input: $input) {
                checkout {
                  id
                }
                checkoutUserErrors {
                      code
                      field
                      message
                }
                queueToken
              }
            }

and input variables is :

{
    "input": {
        "allowPartialAddresses": false,
        "buyerIdentity": {
            "countryCode": "AU"
        },
        "customAttributes": [
            {
                "key": "",
                "value": ""
            }
        ],
        "email": "Karimy.ehsan@gmail.com",
        "note": "test",
        "presentmentCurrencyCode": "AU",
        "shippingAddress": {
            "address1": "15 Barker Street",
            "address2": "",
            "city": "Forest Hill",
            "company": "",
            "country": "Australia",
            "firstName": "Ehsan",
            "lastName": "karimi",
            "phone": "(08) 9073 4623",
            "province": "Western Australia",
            "zip": "6324"
        },
        "lineItems": [
            {
                "customAttributes": [
                    {
                        "key": "",
                        "value": ""
                    }
                ],
                "quantity": 1,
                "variantId": "gid://shopify/ProductVariant/46850414182711"
            }
        ]
    },
    "queueToken": ""
}

and response error is :

{
    "errors": [
        {
            "message": "CheckoutCreateInput isn't a defined input type (on $input)",
            "locations": [
                {
                    "line": 1,
                    "column": 25
                }
            ],
            "path": [
                "mutation checkoutCreate"
            ],
            "extensions": {
                "code": "variableRequiresValidType",
                "typeName": "CheckoutCreateInput",
                "variableName": "input"
            }
        },
        {
            "message": "Field 'checkoutCreate' doesn't exist on type 'Mutation'",
            "locations": [
                {
                    "line": 3,
                    "column": 15
                }
            ],
            "path": [
                "mutation checkoutCreate",
                "checkoutCreate"
            ],
            "extensions": {
                "code": "undefinedField",
                "typeName": "Mutation",
                "fieldName": "checkoutCreate"
            }
        },
        {
            "message": "Variable $input is declared by checkoutCreate but not used",
            "locations": [
                {
                    "line": 1,
                    "column": 1
                }
            ],
            "path": [
                "mutation checkoutCreate"
            ],
            "extensions": {
                "code": "variableNotUsed",
                "variableName": "input"
            }
        }
    ]
}

the post URL is : https://fydez.myshopify.com/admin/api/2023-07/graphql.json
I don't know why receiving this error!!!!!

ShopifyDevSup
Shopify Staff
1453 238 511

Hey @Fydez thanks for sharing those examples. 

Looking at this, the error appears to be that you're calling the admin API, not the storefront API. 

the post URL is : https://storename.myshopify.com/admin/api/2023-07/graphql.json

The checkoutCreate mutation you are using is on the storefront API. For the storefront API, its a slightly different endpoint and access token

 

https://{store_name}.myshopify.com/api/2023-07/graphql.json

- Kyle G.

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Fydez
Shopify Partner
8 0 0

I believe what we are trying to communicate here is that we are using the sample query and schema from the example that you mentioned but we are still getting the error as shown here. Even with no change being applied it still doesnt seem to be working.

Fydez
Shopify Partner
8 0 0

I believe what we are trying to communicate here is that we are using the sample query and schema from the example that you mentioned but we are still getting the error as shown here. Even with no change being applied it still doesnt seem to be working.

usmanwixpa
Shopify Partner
4 0 0