Answers.Body: <p>I might be missing something here but wouldn't passing the current entry's tag IDs rather than the entry ID work for you?</p>
  
  <pre><code>query QueryName {
    entries(
        section: "article",
        limit: 2,
        relatedTo: [123,456] // Current article's tag IDs?
    ) {
        id,
        title
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-09T13:23:01.697Z
Answers.LastActivityDate: 2020-01-09T13:23:01.697Z
Answers.UserDisplayName: Oli
Body: <p>I'm trying to retrieve entries related to the current entry, based on a <code>tag</code> field called <code>topics</code>. Simple stuff.</p>
  
  <p>Now, I use Craft's native GraphQL implementation so I'm bound to the possibilities this interface gives me. In twig, it would be quite easily solved as described in the following topic: <a href="https://craftcms.stackexchange.com/questions/1245/search-for-related-entries-based-on-tags">Search for related entries based on tags</a></p>
  
  <p>It seems like the <code>relatedTo</code> property of the <code>entries()</code> query only supports a single ID, without the ability to scope my results based on a certain field. I would expect to be able to do something like the following:</p>
  
  <pre><code>entries(
      section: "article",
      limit: 2,
      relatedTo: {
          sourceElement: 123, // ID of the current entry
          field: 'topics'
      }
  ) {
      id,
      title
  }
  </code></pre>
  
  <p>This just gives me the following error: <code>Expected type [Int], found {sourceElement: 123, field: \"topics\"}.</code></p>
  
  <p>Now, if I resort to the documentation it indeed describes that only an entry's ID can be used as the value of <code>relatedTo</code>, like this:</p>
  
  <pre><code>query QueryName {
    entries(
        section: "article",
        limit: 2,
        relatedTo: 123 // Current article ID
    ) {
        id,
        title
    }
  }
  </code></pre>
  
  <p>This does work (it doesn't error), but results in an empty <code>entries</code> array. Even though there's entries that have the same <code>topics</code> (tags) assigned to them. </p>
  
  <p>I'm kinda lost on how to actually retrieve related entries. Should I just revert to using the <code>search</code> param and feed it a concatenated list of the current post's tags?</p>
  
  <p>Any elegant solutions would be greatly appreciated!</p>
  
  <p>Thanks in advance!</p>
  
Tags: <craft3><relatedto><graphql>
Title: GraphQL - Get related entries based on tags field
ThreadText: # GraphQL - Get related entries based on tags field
  
  (Asked by: username_0 on 2020-01-09)
  
  I'm trying to retrieve entries related to the current entry, based on a `tag` field called `topics`. Simple stuff.
  
  Now, I use Craft's native GraphQL implementation so I'm bound to the possibilities this interface gives me. In twig, it would be quite easily solved as described in the following topic: [Search for related entries based on tags](https://craftcms.stackexchange.com/questions/1245/search-for-related-entries-based-on-tags)
  
  It seems like the `relatedTo` property of the `entries()` query only supports a single ID, without the ability to scope my results based on a certain field. I would expect to be able to do something like the following:
  
  ```
  entries(
      section: "article",
      limit: 2,
      relatedTo: {
          sourceElement: 123, // ID of the current entry
          field: 'topics'
      }
  ) {
      id,
      title
  }
  
  ```
  
  This just gives me the following error: `Expected type [Int], found {sourceElement: 123, field: \"topics\"}.`
  
  Now, if I resort to the documentation it indeed describes that only an entry's ID can be used as the value of `relatedTo`, like this:
  
  ```
  query QueryName {
    entries(
        section: "article",
        limit: 2,
        relatedTo: 123 // Current article ID
    ) {
        id,
        title
    }
  }
  
  ```
  
  This does work (it doesn't error), but results in an empty `entries` array. Even though there's entries that have the same `topics` (tags) assigned to them.
  
  I'm kinda lost on how to actually retrieve related entries. Should I just revert to using the `search` param and feed it a concatenated list of the current post's tags?
  
  Any elegant solutions would be greatly appreciated!
  
  Thanks in advance!
  
  **Tags:** craft3, relatedto, graphql
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-09. Score: 1
  
  I might be missing something here but wouldn't passing the current entry's tag IDs rather than the entry ID work for you?
  
  ```
  query QueryName {
    entries(
        section: "article",
        limit: 2,
        relatedTo: [123,456] // Current article's tag IDs?
    ) {
        id,
        title
    }
  }
  
  ```
  
  
  ---
  
  