<p>You should be able to use <code>next</code> and <code>prev</code> (<a href="https://craftcms.com/docs/3.x/graphql.html#the-entryinterface-interface" rel="nofollow noreferrer">see documentation</a> and <a href="https://github.com/craftcms/cms/issues/5571" rel="nofollow noreferrer">this issue</a>).</p>
<pre><code>query getEntryData($id: [QueryArgument]) {
  entry(id: $id) {
    id,
    slug,
    title,
    uri,
    prev(section: &quot;blog&quot;, orderBy: &quot;postDate desc&quot;) {
      id,
        slug,
        title,
        uri
    },
    next(section: &quot;blog&quot;, orderBy: &quot;postDate desc&quot;) {
      id,
        slug,
        title,
        uri
    }
  }
}
</code></pre>

CC BY-SA 4.0
2021-03-16T16:42:45.690Z
Thanks @oli that means orderby id required here?
davidhellmann
CC BY-SA 4.0
2021-03-15T14:38:18.427Z
2021-03-15T14:38:18.427Z
Oli
<p>Is there a way to get the prev and next entry from the current entry, when this entry is inside a channel and not a structure?</p>
<pre class="lang-js prettyprint-override"><code>query ($id: [QueryArgument], $rel: Int) {
  entry: entry(id: $id) {
    id
    slug
    title
    uri
  }
  next: entry(nextSiblingOf: $rel) {
    id
    slug
    title
    uri
  }
  previous: entry(prevSiblingOf: $rel) {
    id
    slug
    title
    uri
  }
}
</code></pre>
<p>Output when the entry is in a structure:</p>
<pre class="lang-js prettyprint-override"><code>{
  &quot;data&quot;: {
    &quot;entry&quot;: {
      &quot;id&quot;: &quot;145&quot;,
      &quot;slug&quot;: &quot;neuigkeiten&quot;,
      &quot;title&quot;: &quot;Neuigkeiten&quot;,
      &quot;uri&quot;: &quot;neuigkeiten&quot;
    },
    &quot;next&quot;: {
      &quot;id&quot;: &quot;150&quot;,
      &quot;slug&quot;: &quot;leistungen&quot;,
      &quot;title&quot;: &quot;Leistungen&quot;,
      &quot;uri&quot;: &quot;leistungen&quot;
    },
    &quot;previous&quot;: {
      &quot;id&quot;: &quot;141&quot;,
      &quot;slug&quot;: &quot;unsere-praxis&quot;,
      &quot;title&quot;: &quot;Unsere Praxis&quot;,
      &quot;uri&quot;: &quot;unsere-praxis&quot;
    }
  }
}
</code></pre>
<p>and the result when the entry is inside a channel:</p>
<pre class="lang-js prettyprint-override"><code>{
  &quot;data&quot;: {
    &quot;entry&quot;: {
      &quot;id&quot;: &quot;182&quot;,
      &quot;slug&quot;: &quot;david-hellmann-1-2&quot;,
      &quot;title&quot;: &quot;David Hellmann&quot;,
      &quot;uri&quot;: &quot;team/david-hellmann-1-2&quot;
    },
    &quot;next&quot;: null,
    &quot;previous&quot;: null
  }
}
</code></pre>
<p>is there a way to get this data?</p>

<channels><queries><graphql>
GraphQL: get prev / next entry from current entry (channel)
# GraphQL: get prev / next entry from current entry (channel)

(Asked by: username_0 on 2021-03-12)

Is there a way to get the prev and next entry from the current entry, when this entry is inside a channel and not a structure?
query ($id: [QueryArgument], $rel: Int) {
  entry: entry(id: $id) {
    id
    slug
    title
    uri
  }
  next: entry(nextSiblingOf: $rel) {
    id
    slug
    title
    uri
  }
  previous: entry(prevSiblingOf: $rel) {
    id
    slug
    title
    uri
  }
}

Output when the entry is in a structure:
{
  "data": {
    "entry": {
      "id": "145",
      "slug": "neuigkeiten",
      "title": "Neuigkeiten",
      "uri": "neuigkeiten"
    },
    "next": {
      "id": "150",
      "slug": "leistungen",
      "title": "Leistungen",
      "uri": "leistungen"
    },
    "previous": {
      "id": "141",
      "slug": "unsere-praxis",
      "title": "Unsere Praxis",
      "uri": "unsere-praxis"
    }
  }
}

and the result when the entry is inside a channel:
{
  "data": {
    "entry": {
      "id": "182",
      "slug": "david-hellmann-1-2",
      "title": "David Hellmann",
      "uri": "team/david-hellmann-1-2"
    },
    "next": null,
    "previous": null
  }
}

is there a way to get this data?

**Tags:** channels, queries, graphql


---

## 1 answers

### Answer by username_1 on 2021-03-15. Score: 4 | Accepted answer

You should be able to use next and prev (see documentation and this issue).
query getEntryData($id: [QueryArgument]) {
  entry(id: $id) {
    id,
    slug,
    title,
    uri,
    prev(section: "blog", orderBy: "postDate desc") {
      id,
        slug,
        title,
        uri
    },
    next(section: "blog", orderBy: "postDate desc") {
      id,
        slug,
        title,
        uri
    }
  }
}

> **Comments:**
> **username_0**: Thanks @oli that means orderby id required here?  

---

