Answers.Body: <p>No, I don't think so. If you think about it, assets are always an array so treat them consistently as such, even if you've set a limit of one. If the backend limit changes, it won't screw with your setup, either.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-12-03T22:29:05.593Z
Answers.LastActivityDate: 2021-12-03T22:29:05.593Z
Answers.UserDisplayName: Clive Portman
Body: <p>Consider the following GraphQL query:</p>
  <pre><code>{
    entries {
      ...on posts_default_Entry {
        image {
          id
        }
      }
    }
  }
  </code></pre>
  <p>This will return the following:</p>
  <pre><code>{
    &quot;data&quot;: {
      &quot;entries&quot;: [
        {
          &quot;image&quot;: [
            {
              &quot;id&quot;: &quot;11010&quot;
            }
          ]
        }
      ]
    }
  }
  </code></pre>
  <p>However, since the <code>image</code> field is limited to 1 image, it doesn't make sense for it to be an array. I would prefer that the query returned the following instead:</p>
  <pre><code>{
    &quot;data&quot;: {
      &quot;entries&quot;: [
        {
          &quot;image&quot;: {
            &quot;id&quot;: &quot;11010&quot;
          }
        }
      ]
    }
  }
  </code></pre>
  <p>Is this possible?</p>
  
Tags: <graphql>
Title: Return a single element instead of an array in a GraphQL query
ThreadText: # Return a single element instead of an array in a GraphQL query
  
  (Asked by: username_0 on 2021-12-02)
  
  Consider the following GraphQL query:
  
  ```
  {
    entries {
      ...on posts_default_Entry {
        image {
          id
        }
      }
    }
  }
  
  ```
  
  This will return the following:
  
  ```
  {
    "data": {
      "entries": [
        {
          "image": [
            {
              "id": "11010"
            }
          ]
        }
      ]
    }
  }
  
  ```
  
  However, since the `image` field is limited to 1 image, it doesn't make sense for it to be an array. I would prefer that the query returned the following instead:
  
  ```
  {
    "data": {
      "entries": [
        {
          "image": {
            "id": "11010"
          }
        }
      ]
    }
  }
  
  ```
  
  Is this possible?
  
  **Tags:** graphql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-12-03. Score: 2 | Accepted answer
  
  No, I don't think so. If you think about it, assets are always an array so treat them consistently as such, even if you've set a limit of one. If the backend limit changes, it won't screw with your setup, either.
  
  
  ---
  
  