GraphQL,是否可以构造我的类型以返回零件/所有查询输入过滤器参数?

时间:2019-09-17 19:03:16

标签: graphql

是否可以构造我的类型以直接从查询中返回参数?

查询将用作过滤器一部分的输入...

input DateRange {
  startDate: String!
  endDate: String
}

如何返回以下内容?

type ReturnData {
  _id: String
  startDate: DateRange.startDate  // while dot notation isn't possible is there another way to return the parameters

  color: String
  size: String
  ... 
}

我的查询的结构如此...

type Query {
  getEquipment(filter: DateRange):ReturnData!
}

编辑:我发现的一个解决方案是将我的类型格式化为...

type DiagnosticsBannerTracking {
  _id: String
  startDate: String
  color: String
  size: String
  ...
}

然后在我的解析器中从startDate抓取args,然后将其返回。但我想知道是否还有更直接的路线。

0 个答案:

没有答案