No ID field for GLB?

BeamJokerFavor
Excursionist
39 2 2

I wish to reorder my product images so the GLB is the first image. However when I look at the fields for Media, the Model3d is missing and id field. How do I move the GLB without an id field to select? I also get the error "Field 'id' doesn't exist on type 'Media'",

fragment fieldsForMediaTypes on Media {
  alt
  mediaContentType
  preview {
    image {
      id
      altText
      originalSrc
    }
  }
  status
  ... on Video {
    id
    sources {
      format
      height
      mimeType
      url
      width
    }
    originalSource {
      format
      height
      mimeType
      url
      width
    }
  }
  ... on ExternalVideo {
    id
    embeddedUrl
  }
  ... on Model3d {
    sources {
      format
      mimeType
      url
    }
    originalSource {
      format
      mimeType
      url
    }
  }
  ... on MediaImage {
    id
    image {
      altText
      originalSrc
    }
  }
}
0 Likes
BeamJokerFavor
Excursionist
39 2 2

The ID field does exist according to the API reference. This must be a typo in the example.

I found the original example here: https://shopify.dev/tutorials/manage-product-media-with-admin-api

0 Likes
BeamJokerFavor
Excursionist
39 2 2

The only gid I see is for the preview jpg, which is invalid for reordering.

 

This is my query. How do I get the id?

  query = '''query($id: ID!){ 
    product(id: $id) {
    title
    media(first:1) {
      edges {
        node {
          ... fieldsForMediaTypes
        }
      }
    }
  }
}

fragment fieldsForMediaTypes on Media {
  alt
  mediaContentType
  preview {
    image {
      id
      altText
      originalSrc
    }
  }
  status
  ... on Model3d {
    id
    sources {
      format
      mimeType
      url
    }
    originalSource {
      format
      mimeType
      url
    }
  }
  
}
0 Likes
CalD
Shopify Staff
Shopify Staff
139 20 28

Hey @BeamJokerFavor,

What's the response you're getting with that fragment?

Here's mine, which does return the model3d's id, using a very similar request without preview images:

{
  product(id:"gid://shopify/Product/5611962236950") {
    title
    media(first:1) {
      edges {
        node {
          ... fieldsForMediaTypes
        }
      }
    }
  }
}

fragment fieldsForMediaTypes on Media {
  alt
  mediaContentType
  status
  ... on Model3d {
    id
    sources {
      format
      mimeType
      url
    }
  }
}

 response:

{
  "data": {
    "product": {
      "title": "Pot and Saucer",
      "media": {
        "edges": [
          {
            "node": {
              "alt": "",
              "mediaContentType": "MODEL_3D",
              "status": "READY",
              "id": "gid:\/\/shopify\/Model3d\/20164237459478",
              "sources": [
                {
                  "format": "glb",
                  "mimeType": "model\/gltf-binary",
                  "url": "https:\/\/model3d.shopifycdn.com\/models\/o\/517cffab171ed5bb\/pot-saucer.glb"
                },
                {
                  "format": "usdz",
                  "mimeType": "model\/vnd.usdz+zip",
                  "url": "https:\/\/model3d.shopifycdn.com\/models\/o\/b6e27223f40e2e06\/pot-saucer.usdz"
                }
              ]
            }
          }
        ]
      }
    }
  }
}

 

 

CalD | Developer Support @ Shopify 
 - Was my reply helpful? Click Like to let me 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

0 Likes
BeamJokerFavor
Excursionist
39 2 2

Yes, I was able to get the ID to appear. I think the problem was I copied-and-pasted the example. I added the field back and it appeared. Thank you for your help and sorry for the trouble.

0 Likes