Create Checkout

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 ‌‌ :sob: :

{
    "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"
            }
        }
    ]
}

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.

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

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

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!!!

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.

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.

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.

this documentation will help you
https://shopify.dev/docs/custom-storefronts/building-with-the-storefront-api/cart/manage