首页 > 解决方案 > 使用 Amplify Codegen 自定义 GraphQL 查询

问题描述

我正在使用带角度的放大 cli。我已经生成了基于模式的 GraphQL API。我需要编写自定义查询并使用amplify codegen.

现在,我知道我可以在文件中编写自定义查询src/graphql/**/*.graphql以仅获取选定的字段,但被调用的底层函数必须已经存在于 schema.json 中 - 例如在下面的代码片段中

query QueryCustom($id:ID!){
 getRelationship(id: $id){     <=== this must be present in schema.json
    id
    sourceId
    targetId
 }
}

这限制了我能够为查询编写自定义函数(1)以应用基于不同字段的过滤器(例如在上述场景中,基于 sourceId 或 targetId)(2)将我的查询扩展到多个 dynamoDB 表等。

感谢您提供有关如何实现上述(1)和(2)的一些指示

标签: angulargraphqlamazon-dynamodbaws-amplify

解决方案


推荐阅读