我正在通过AWS-Amplify创建一个具有项目类型和接口类型的GraphQL模式。每个项目都有多个接口(一对多)。在界面的属性中,如何过滤/验证用户可以输入的内容?例如。对于项目1,接口1,频率只能是每小时,每周,每月,每年。另一个示例是在Project 1(接口1)中,状态只能是活动或不活动。我应该如何实施这些类型的设置/更改?
截至目前,我的schema.graphql如下所示:
type Project
@model
@auth(rules: [{allow: owner}])
{
project_number: ID!
name: String!
interfaces: [Interface] @connection(name: "ProjectInterfaces")
}
type Interface
@model
@auth(rules: [{allow: owner}])
{
unique_id: String!
external_id: String!
interface_name: String!
version: String!
release: String!
source_feature: String!
state: String!
source_application: String!
source_env: String!
source_go_live: String!
source_payload: String!
source_payload_format: String!
payload_volume: String!
source_protocol: String!
target_application: String!
target_env: String!
target_go_live: String!
target_payload: String!
target_payload_format: String!
target_payload_volume: String!
target_protocol: String!
frequency: String!
authentication: String!
payload_security: String!
transport_security: String!
network_paths: String!
project: Project @connection(name: "ProjectInterfaces")
}
总而言之,假设某人想添加一个界面,并输入“ Bi-Weekly”(每周一次)作为频率,他们将不允许用户添加界面,因为仅每小时,每周,每月,每年都将被接受。然后,将向用户显示可以在该界面中输入的正确输入。