【发布时间】:2018-04-13 21:18:32
【问题描述】:
背景
我们正在开发一个相当大的Apollo 项目。我们的 api 的一个非常简化的版本如下所示:
type Operation {
foo: String
activity: Activity
}
type Activity {
bar: String
# Lots of fields here ...
}
我们已经意识到拆分 Operation 和 Activity 没有任何好处,而且会增加复杂性。我们想合并它们。但是有很多查询在代码库中采用这种结构。为了使过渡渐进,我们添加了@deprecated 指令:
type Operation {
foo: String
bar: String
activity: Activity @deprecated
}
type Activity {
bar: String @deprecated(reason: "Use Operation.bar instead")
# Lots of fields here ...
}
实际问题
有什么方法可以突出这些弃用的未来吗?最好在(在测试环境中)运行使用已弃用字段的查询时在浏览器控制台中打印警告?
【问题讨论】:
-
我认为它可以在apollo-client 中间件中完成?
-
我也对执行此操作的某种实现或工具感兴趣 :)
-
@Striped 在下面添加了解决方案。
标签: graphql apollo apollo-client