首页 > 解决方案 > 对 GraphQl 查询不区分大小写进行排序

问题描述

与此相同的问题:GraphQL 排序不区分大小写 ,即我需要按字母顺序对查询结果进行排序,但它首先返回以大写字母开头的帖子,然后是小写字母。我只想要完全按字母顺序。

但我不知道如何让上面的答案与盖茨比一起工作。

我的查询如下所示:

query {
  allMdx(
    sort: {fields: frontmatter___title, order: ASC}
  ) {
    nodes {
      frontmatter {
        title
        slug
      }
      id
    }
  }
}

我的组件如下所示:

const AlphabeticalIndex = ({data}) => {
  return (
    <Layout pageTitle="Alphabetical Index">
    <div>
      {
        data.allMdx.nodes.map(node => (
          <p key={node.frontmatter.title} className={listLink}>
            <Link to={"/" + node.frontmatter.slug}>
            {node.frontmatter.title}
            </Link>
          </p>
        ))
      }
      </div>
    </Layout>
  )
}

该网站已上线,您可以在此处查看当前查询结果https://ausdict.translatableenglish.com/entry-index(脏话的内容警告)。

谢谢您的帮助。

标签: javascriptreactjsapigraphql

解决方案


推荐阅读