Answers.Body: <p>So I'm wondering the same thing, I'm using CraftQL as I need to support mutations, and I am close with this - but I get an error if I try to use $id instead of a hard-wired Int (e.g. 99): </p>
  
  <pre><code>
  query getEntryData($id: [Int]) {
    prevEntry: entry(prevSiblingOf: 99) {
      id
      title
      slug
      uri
    }
    nextEntry: entry(nextSiblingOf: 99) {
      id
      title
      slug
      uri
    }
    entryData: entry(section: investigations, id: $id) {
      id
      title
      slug
      uri
    }
  }
  </code></pre>
  
  <p>I get the following error: </p>
  
  <pre><code>"message": "Variable \"$id\" of type \"[Int]\" used in position expecting type \"Int\".",
  </code></pre>
  
  <p>BUT then if I pass the $id as Int (and not [Int]) it works. Can't explain the typing difference. </p>
  
  <pre><code>query getEntryData($id: [Int], $sameId: Int) {
  
     prev:entry(prevSiblingOf: $sameId) {
      id
      title
      slug
      uri
    }
    next: entry(nextSiblingOf: $sameId) {
      id
      title
      slug
      uri
    }
    investigation: entry(section: investigations, id: $id) {
      id
      title
      slug
      uri
    }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-27T22:47:31.907Z
Answers.LastActivityDate: 2020-01-28T14:38:02.563Z
Answers.LastEditDate: 2020-01-28T14:38:02.563Z
Answers.UserDisplayName: littlered
Answers.Body: <p>@littered</p>
  
  <p>your example is working when you unwrap the Int param in your query. This should work: </p>
  
  <pre><code>query getEntryData($id: Int) {
    prevEntry: entry(prevSiblingOf: $id) {
      id
      title
      slug
      uri
    }
    nextEntry: entry(nextSiblingOf: $id) {
      id
      title
      slug
      uri
    }
    entryData: entry(section: investigations, id: [$id]) {
      id
      title
      slug
      uri
    }
  }
  
  </code></pre>
  
  <p>the id field in <code>entryData</code> is expecting a <code>QueryArgument</code> of type [Int] but prevSiblingOf/nextSiblingOf expect an Int. With the above fix you submit a integer and wrap it for the <code>entryData</code> in an Array.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-04-27T07:59:54.830Z
Answers.LastActivityDate: 2020-04-27T07:59:54.830Z
Answers.UserDisplayName: Denis
Body: <p>How do I turn these Craft queries into a GraphQL one?</p>
  
  <pre><code>// entry.twig
  
  entry.getPrev({ section: "contentHub" })
  entry.getNext({ section: "contentHub" })
  </code></pre>
  
  <p>I want to get the previous and next entry using the current entry</p>
  
Tags: <craft3><query><graphql>
Title: How to get previous and next entry using the native GraphQL API?
ThreadText: # How to get previous and next entry using the native GraphQL API?
  
  (Asked by: username_0 on 2019-11-25)
  
  How do I turn these Craft queries into a GraphQL one?
  
  ```
  // entry.twig
  
  entry.getPrev({ section: "contentHub" })
  entry.getNext({ section: "contentHub" })
  
  ```
  
  I want to get the previous and next entry using the current entry
  
  **Tags:** craft3, query, graphql
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2020-01-27. Score: 3
  
  So I'm wondering the same thing, I'm using CraftQL as I need to support mutations, and I am close with this - but I get an error if I try to use $id instead of a hard-wired Int (e.g. 99):
  
  ```
  
  query getEntryData($id: [Int]) {
    prevEntry: entry(prevSiblingOf: 99) {
      id
      title
      slug
      uri
    }
    nextEntry: entry(nextSiblingOf: 99) {
      id
      title
      slug
      uri
    }
    entryData: entry(section: investigations, id: $id) {
      id
      title
      slug
      uri
    }
  }
  
  ```
  
  I get the following error:
  
  ```
  "message": "Variable \"$id\" of type \"[Int]\" used in position expecting type \"Int\".",
  
  ```
  
  BUT then if I pass the $id as Int (and not [Int]) it works. Can't explain the typing difference.
  
  ```
  query getEntryData($id: [Int], $sameId: Int) {
  
     prev:entry(prevSiblingOf: $sameId) {
      id
      title
      slug
      uri
    }
    next: entry(nextSiblingOf: $sameId) {
      id
      title
      slug
      uri
    }
    investigation: entry(section: investigations, id: $id) {
      id
      title
      slug
      uri
    }
  }
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2020-04-27. Score: 1
  
  @littered
  
  your example is working when you unwrap the Int param in your query. This should work:
  
  ```
  query getEntryData($id: Int) {
    prevEntry: entry(prevSiblingOf: $id) {
      id
      title
      slug
      uri
    }
    nextEntry: entry(nextSiblingOf: $id) {
      id
      title
      slug
      uri
    }
    entryData: entry(section: investigations, id: [$id]) {
      id
      title
      slug
      uri
    }
  }
  
  ```
  
  the id field in `entryData` is expecting a `QueryArgument` of type [Int] but prevSiblingOf/nextSiblingOf expect an Int. With the above fix you submit a integer and wrap it for the `entryData` in an Array.
  
  
  ---
  
  