【发布时间】:2019-12-24 15:20:49
【问题描述】:
我有一个输入类型,其中有两个字段用于过滤客户端上的查询。
我想将默认值 (rentIntervalLow + rentIntervalHigh) 从服务器传递到客户端,但不知道该怎么做。
以下是我当前的代码。我想出了两个幼稚的解决方案:
让客户端内省整个架构。
拥有一个全局配置对象,并使用返回配置对象值的解析器创建一个可查询的
Config类型。
有什么比上述更好的建议如何使客户端可以访问服务器上的默认/配置值?
// schema.js
const typeDefs = gql`
input FilteringOptions {
rentIntervalLow: Int = 4000
rentIntervalHigh: Int = 10000
}
type Home {
id: Int
roomCount: Int
rent: Int
}
type Query {
allHomes(first: Int, cursor: Int, input: FilteringOptions): [Home]
}
`
export default typeDefs
我正在使用 Apollo Server 2.8.1 和 Apollo React 3.0。
【问题讨论】:
标签: graphql react-apollo apollo-server