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
1248 201 442

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.