AWS AppSync - 使用自定义指令定义 GraphQL 架构

AWS AppSync - Defining GraphQL schema with custom directives

定义此自定义指令时:

directive @hashField on INPUT_FIELD_DEFINITION

我在 AWS AppSync(架构选项卡)上收到此错误:

Error parsing schema. Directive definitions are not supported.

我了解 AWS 提供的 functions 可以提供类似的功能,但这些功能不适用于我的用例。

AWS AppSync 中自定义指令的替代方法是什么?未来版本会支持它吗?

显然他们的路线图中没有添加指令支持。

另一种选择可以是自定义 scalar types;但是,它不符合我的要求,因为我需要指定应用于特定字段的多个指令的顺序。

有趣的是,使用 AWS CDK,Directive.custom 方法在字段和对象级别都可用,例如

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")')
    ]
});