How to retrieve and update the SEO object using storefront API?

I am abit confused on how to utilize this documentation? https://shopify.dev/docs/api/storefront/2023-01/objects/SEO I am aware that I will need to use the graph QL api, but the document is not clear compared to examples provided for other api use.

Hi @Iciren :waving_hand:

Storefront API supports reading the SEO object, and Admin API is required to modify them. Using Collection.SEO as an example:

  • SFAPI can query a collection to read the seo field:
{
    collection(id: "gid://shopify/Collection/123") {
        seo {
            description
            title
        }
    }
}
mutation ($input: CollectionInput!) {
    collectionUpdate(input: $input) {
        collection {
            seo{
                title
                description
            }
        }
    }
}
{
    "input": {
        "id": "gid://shopify/Collection/123",
        "seo": {
            "title": "foo",
            "description": "bar"
        }
    }
}

Hope that helps!