I can't seem to figure out how to order items by position

I am using the gatsby-source-datocms

In the dato API Explorer I can order posts by position like so

query MyQuery {
  allProjects(orderBy: position_ASC) {
    slug
  }
}

However in Gatsby the same query alludes me I have tried something like this below but it gives me this error Expected type SortOrderEnum, found position_ASC

query MyQuery {
  allDatoCmsProject(sort: {order: position_ASC}) {
    edges {
      node {
        slug
      }
    }
  }
}

hello @hi

sorry for the delay here, but I can reproduce your issue. Looks like a bug on our source plugin, from what I can tell.

Weโ€™ll be in touch when itโ€™s fixed, sorry for that :frowning:

uhm, have you tried to sort using this syntax:

sort: {fields: position, order: ASC}

Gatsbyโ€™s flavour of GraphQL is a bit different from the standard one, sorry I have missed that!

yeah I ended up figuring it out and the worked thanks

1 Like