簡體   English   中英

帶有AWS Amplify的GraphQL-如何啟用查詢排序

[英]GraphQL with AWS Amplify - how to enable sorting on query

我最近開始研究AWS Amplify。 我設法使用GraphQl設置了API。 基本上,在創建API的過程中,Amplify向您詢問有關API的幾個問題,並指導您完成其創建過程。 在某些時候,要求您創建一個架構。 我選擇的架構如下:

type User @model {
  id: ID!
  username: String!
  email: String
}

type Highscore @model {
  points: Int!,
  id: ID!
  ownerId: ID!,
  numRounds: Int,
  date: String, 
}

通過這種模式,Amplify能夠生成允許我執行以下操作的代碼:

  • 變異用戶和高分
  • 查詢所有用戶
  • 查詢所有高分

有誰知道我怎么能做到這一點?

我研究了@key指令( https://aws-amplify.github.io/docs/cli-toolchain/graphql#key ),但將架構更新為包括

type Highscore @model @key((fields: ["points"] {
...
}

沒有產生預期的結果。

不幸的是,Amplify使用此架構生成的代碼不允許對query進行排序

我希望能夠查詢所有的高分,並根據分數對它進行排序。

提出了這個問題,並已在GitHub Amplify CLI回購中回答。 https://github.com/aws-amplify/amplify-cli/issues/2307

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM