Reputation: 864
I have a Post
content type, which has a FeaturedImage
field. Because this field is an image upload, Strapi generates handy additional formats: thumbnail
, small
, medium
and large
.
When I query all posts in JSON, I get these formats in the response:
{
"id": 1,
"Title": "Hello World",
"Content": "Nullam id dolor id nibh ultricies vehicula ut id elit..",
"FeaturedImage": {
"id": 1,
"name": "angel-jimenez-168185",
"alternativeText": "",
"caption": "",
"width": 2768,
"height": 1560,
"formats": {
"thumbnail": {
"hash": "thumbnail_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 245,
"height": 138,
"size": 6.22,
"path": null,
"url": "/uploads/thumbnail_angel_jimenez_168185_aaceac7acf.jpeg"
},
"large": {
"hash": "large_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 1000,
"height": 564,
"size": 75.71,
"path": null,
"url": "/uploads/large_angel_jimenez_168185_aaceac7acf.jpeg"
},
"medium": {
"hash": "medium_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 750,
"height": 423,
"size": 41.8,
"path": null,
"url": "/uploads/medium_angel_jimenez_168185_aaceac7acf.jpeg"
},
"small": {
"hash": "small_angel_jimenez_168185_aaceac7acf",
"ext": ".jpeg",
"mime": "image/jpeg",
"width": 500,
"height": 282,
"size": 19.69,
"path": null,
"url": "/uploads/small_angel_jimenez_168185_aaceac7acf.jpeg"
}
}
}
}
However, if I query in GraphQL, only the publicURL
for the original (full size) image is available:
How I access these image formats with GraphQL?
Upvotes: 5
Views: 3720
Reputation: 1156
This query is showing me all of the expected formats objects:
query MyQuery {
strapi {
home {
content {
image {
formats
}
}
}
}
}
I did explicitly install the graphql plugin on strapi https://strapi.io/documentation/3.0.0-beta.x/plugins/graphql.html#usage
and I am using /graphql in my api url (e.g. http://localhost:1337/graphql).
I hope that helps, @jgthms
FYI strapi v.3.1.4 strapi-plugin-graphql v.3.1.4
Upvotes: 3
Reputation: 13
I ran into the same issue today and have tried to solve this for admittedly too long. It seems that the issue is that when querying is that "formats" is of type JSON and it won't let it be queried. I'm not really sure why this is happening or how to resolve it though. Any advice would be helpful.
Upvotes: -1