Identifying media that has been uploaded using GraphQL

I’m using the ProductCreate mutation of the GraphQL Admin API. I’m currently using the images node to upload images for my product (often three or four per product) and I need to know the IDs of the images in Shopify once they’re uploaded (the gid://shopify/ProductImage/XXXXX value). Has anyone found a reliable way of matching up the ID to the images that have been uploaded? I’m currently looking for the image name that I uploaded in the URL of the uploaded image, but that doesn’t always work, as Shopify has a habit of inserting GUIDs in the image URLs.

I’m aware that the images node is deprecated and I’ll need to use the media object, instead, but I imagine I’ll have the same problem there. Is there not a way to add an ID to an image that I can then use to work out which is which in the return data?