[英]AWS AppSync - Defining GraphQL schema with custom directives
在定義此自定義指令時:
directive @hashField on INPUT_FIELD_DEFINITION
我在 AWS AppSync(架構選項卡)上收到此錯誤:
解析架構時出錯。 不支持指令定義。
我了解 AWS 提供的函數可以提供類似的功能,但這些函數不適用於我的用例。
AWS AppSync 中自定義指令的替代方案是什么? 它會在未來的版本中得到支持嗎?
顯然,添加指令支持不在他們的路線圖中。
另一種可能是自定義標量類型; 但是,它不符合我的要求,因為我需要指定應用於特定字段的多個指令的順序。
有趣的是,使用 AWS CDK,Directive.custom 方法在字段和 object 級別都可用,例如
import { Field, GraphqlType, InterfaceType, ObjectType, Directive } from '@aws-cdk/aws-appsync-alpha';
new ObjectType('MyObjectType', {
definition: {
id: GraphqlType.id({ isRequired: true }),
name: new Field({ returnType: GraphqlType.string(), directives: [Directive.custom('@myCustomFieldDirective(param: "value")')] })
},
directives: [
Directive.custom('@myCustomObjectDirective(param: "value")')
]
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.