I am trying to fetch srcset with GraphQL from Craft4 but I don't really understand the syntax. In my twig Templates I use image.getSrcset(['1x','2x'],'myTransformHandle')
and I'm trying to translate that to GraphQl
If I use srcset(sizes: ["1x","2x"])
it returns a set with the original image and one upscaled to double the size which doesn't seem that useful.
Has anyone worked with this and knows how to get a useful result?
Thanks
Add a comment
|
2 Answers
Inside asset interface you can put the srcset field, here is an example:
{
asset {
srcset(sizes:["1x", "1.5x", "2x"])
}
}
I found some answers in this post right here: https://github.com/craftcms/cms/issues/11982 although it still seems like GQL srcset is highly unflexible. But maybe this helps someone:
myTransformHandle: image @transform(handle: "myTransformHandle") {
srcset(sizes:["1x","2x"])
}