Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: cartCreate graphql API not working

cartCreate graphql API not working

ChandanDreamz
Shopify Partner
1 0 0

I am trying to use cartCreate  API through Postman, but not getting success result

here I am sharing my request body

QUERY

mutation cartCreate($inputCartInput!) {
  cartCreate(input$input) {
    cart {
      id
    }
    userErrors {
      field
      message
    }
  }
}
 
GRAPHQL VARIABLES
 
{
  "input": {
    "lines": [
      {
        "quantity"5,
        "merchandiseId""gid://shopify/ProductVariant/XXXXXXXX386"
      },
         {
        "quantity"2,
        "merchandiseId""gid://shopify/ProductVariant/XXXXXXXX034"
      }
    ]
  
  }
}
 
RESPONSE
-------------------
 
{
    "errors": [
        {
            "message""CartInput isn't a defined input type (on $input)",
            "locations": [
                {
                    "line"1,
                    "column"21
                }
            ],
            "path": [
                "mutation cartCreate"
            ],
            "extensions": {
                "code""variableRequiresValidType",
                "typeName""CartInput",
                "variableName""input"
            }
        },
        {
            "message""Field 'cartCreate' doesn't exist on type 'Mutation'",
            "locations": [
                {
                    "line"3,
                    "column"3
                }
            ],
            "path": [
                "mutation cartCreate",
                "cartCreate"
            ],
            "extensions": {
                "code""undefinedField",
                "typeName""Mutation",
                "fieldName""cartCreate"
            }
        },
        {
            "message""Variable $input is declared by cartCreate but not used",
            "locations": [
                {
                    "line"1,
                    "column"1
                }
            ],
            "path": [
                "mutation cartCreate"
            ],
            "extensions": {
                "code""variableNotUsed",
                "variableName""input"
            }
        }
    ]
}
 
Please help me out. Thanks
Replies 2 (2)

ShopifyDevSup
Shopify Staff
1453 238 522

Hi @ChandanDreamz,

 

Thanks for your post. When testing the query and variables you provided in both a recent version of Postman as well as Insomnia in a test store using variant id's from the test store it's working normally. 

 

This indicates the problem is something relating to local usage of the app or it's settings which is beyond our direct scope of support so perhaps the community will have further ideas.

 

Hope you have a great day,
Jon551

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

testexpinator
Shopify Partner
1 0 0

I am also facing the same issue "CartInput is not a valid type" but according to the documentation CartInput is a valid type.