Sorting by Position discrepancy

Describe the issue:

  • Please include any relevant error messages, screenshots, and troubleshooting you’ve already tried.

I am trying to sort a list of entries by their position on Dato; the issue is that the position displayed on the CMS is different from the position I get whenever I do the graphql query (see screenshots).

(Optional) Can you provide a link to the item, model, or project in question?

(Optional) Do you have any sample code you can provide?

{
      allDatoCmsCancerLeadership(
        sort: { fields: position, order: ASC  }
        filter: { meta: { status: { eq: "published" } } }
      ) {
        edges {
          node {
            slug
            position
            roleTitle
            credentials
            id
            fullName
            portrait {
              gatsbyImageData(width: 64)
            }
            meta {
              status
            }
          }
        }
      }
    }

Hi @jgiraldo,

Is this possibly the result of Gatsby (or another framework you’re using?) rewriting our GraphQL results into its own system? Might you be able to provide some sample code (or repo access) for the file in question? Is it possible it’s caching some of the results from a previous fetch?

If you use our own GraphQL playground in your project with a query in our own schema (notice the different model names in your real project vs your sample code), the results seem normal to me:

{
  allCancerLeaderships(orderBy: position_ASC) {
    id
    fullName
    position
  }
}

In that playground gives us:

{
  "data": {
    "allCancerLeaderships": [
      {
        "id": "23533557",
        "fullName": "Hannah Hazard-Jenkins",
        "position": 4
      },
      {
        "id": "141787454",
        "fullName": "A. Courtney DeVries",
        "position": 5
      },
      {
        "id": "121798271",
        "fullName": "Edward I. Harrison",
        "position": 6
      },
       // snipped
    ]
  }
}

This leads me to believe it might be something your frontend is doing, not our API. If you can provide some sample code, we’ll do our best to look at it with you? We’re not experts in Gatsby, but we’d be happy to take a look!

Sorry @jgiraldo, are you possibly using gatsby-source-datocms | Gatsby to fetch your records? I wonder if it might be a bug in that plugin of ours… let me double-check, if so