在模式中定义查询时,如何引用先前声明的GraphQLEnumType的值,将其用作参数的默认值?
假设我已经定义了以下ObservationPeriodGraphQLEnumType:
observationPeriodEnum = new GraphQLEnumType {
name: "ObservationPeriod"
description: "One of the performance metrics observation periods"
values:
Daily:
value: '1D'
description: "Daily"
[…]
}
Run Code Online (Sandbox Code Playgroud)
并将其用作查询参数的类型period:
queryRootType = new GraphQLObjectType {
name: "QueryRoot"
description: "Query entry points to the DWH."
fields:
performance:
type: performanceType
description: "Given a portfolio EID, an observation period (defaults to YTD)
and as-of date, as well as the source performance engine,
return the matching performance metrics."
args:
period:
type: observationPeriodEnum
defaultValue: observationPeriodEnum.Daily …Run Code Online (Sandbox Code Playgroud)