Mutation menuCreate, Internal error. Looks like something went wrong on our end.

Mutation menuCreate, Internal error. Looks like something went wrong on our end.

lagosand
Shopify Partner
2 0 0

Hi, 

 

I'm trying to create a shop menu using the Graphql Admin API, one day ago was working totally fine but for some reason today I get this "Internal error. Looks like something went wrong on our end." error. The code is written in PowerShell. I will provide an example of what I am doing.

 

I tried with library "2024-10" and "2024-07" but with same output from both.

 

The graphql mutation is extracted directly from the documentation here

 

$library = "2024-10"

function Invoke-GraphQL($query, $vars) {
    $uri = "https://" + $basestoreURL + "admin/api/" + $library + "/graphql.json"
    
    $headers = @{
        "X-Shopify-Access-Token" = $ControlPanelApiToken
        "Content-Type" = "application/json"
    }

    if ($vars) {
        $body = @{
            query = $query
            variables = $vars
        } | ConvertTo-Json -Depth 10 -Compress
    }
    else 
    {
        $body = @{
            query = $query
        } | ConvertTo-Json -Depth 10 -Compress
    }

    $results = Invoke-WebRequest -Method POST -Uri $uri -Header $headers -Body $body -UseBasicParsing

    return $results
}   

function New-ShopMenu($menu) {
    $query = '
    mutation CreateMenu($title: String!, $handle: String!, $items: [MenuItemCreateInput!]!) { 
        menuCreate(title: $title, handle: $handle, items: $items) { 
            menu { 
                id 
                handle 
                items { 
                    id 
                    title 
                    items { 
                        id 
                        title 
                    } 
                } 
            } 
        } 
    }'

    $result = Invoke-GraphQL $query $menu
}

$sidebarMenu = @{
    title = "Todas las categorías"
    handle = "sidebar-menu"
    items = @()
}

$sidebarMenu.items += @{
    title = "Todos los productos"
    url = "/collections/todos-los-productos"
    type = "COLLECTION"
    resourceId = ...
}

// ... More appends here //

New-ShopMenu $sidebarMenu

 

 

The purpose of doing it this way is because the huge amount of collections and menus we need to create.

 

Thanks.

Replies 2 (2)

lagosand
Shopify Partner
2 0 0

Finally I could found the issue, was a problem with the collections that I was trying to attach on the menu. But, even though will be great if instead of an generic internal error, we can get some more specific one like a 404 the collection doesn't exists or something similar.

 

PaulNewton
Shopify Partner
7536 666 1592

@lagosand use https://community.shopify.dev/ to raise issues and feature requests.

This is the shopify SCRIPTS forum for checkout not arbitrary forum for anything "script"ing related. 

"Personalized checkout and custom promotions with Shopify Scripts"

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org