TransWikia.com

GraphQL returning array on entries field with limit set to 1, instead of 1 object/entry

Craft CMS Asked by Ramon Leenders on February 19, 2021

If I do a GraphQL query on an asset (entries field type, limit set to 1), I get an array in return. Even if I limited the asset to just 1 in the field. So my GraphQL returns:

"image": [
  { "alt": "some alt text", "src": "http://the-image.jpg" }
]

With GraphQL:

image {
  alt: title
  src: url
}

Now is it possible to return just the first object in GraphQL one way or another? If not, what function should I look into when I copy/past the existing assets field type into my own custom field type returning just the first value of the array? I couldn’t find it when looking into the field types, so must be some magic method I am guessing (or not possible at all)?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP