I want a single element/entry from the GraphQL-API instead of a list. How do I get it?
This would be possible in craft templates via one (): https://docs.craftcms.com/v3/dev/element-queries/#one
Example Query:
query getProduct($slug: [String]!) {
product: entries(section: "products", slug: $slug) {
id
}
}
Response:
javascript{
"data": {
"product": [
{
"id": "8"
}
]
}
}
Thanks
Yeah, okay. We'll add that for 3.4, but that'll be an entry query, as opposed to entries.
Just pushed this for the next Craft 3.4 release. You can now use the singular forms of the queries (entries -> entry) to return a single result.
Most helpful comment
Yeah, okay. We'll add that for 3.4, but that'll be an
entryquery, as opposed toentries.