小编ola*_*nge的帖子

如何使用GraphQLEnumType中的名称作为GraphQL查询参数的defaultValue?

在模式中定义查询时,如何引用先前声明的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)

graphql graphql-js

6
推荐指数
1
解决办法
1759
查看次数

标签 统计

graphql ×1

graphql-js ×1