![](/img/trans.png)
[英]With AWS Amplify Auth and GraphQL API, how would you have some public, and some private query/mutation calls?
[英]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.