我们已经在项目中看到了许多成功的GraphQL实现,也看到了一些有趣的模式和应用,比如将GraphQL用于服务器端资源聚合。尽管如此,对该框架的滥用、以及使用过程可能遇到的一些问题,我们并非毫无担忧。例如N+1查询可能带来的性能问题,以及添加新模型时需要大量样板代码而导致的复杂性等。这些问题有一些解决方法,例如使用查询缓存等。虽然这项技术不是银弹,我们仍然认为它值得作为系统架构的一部分进行评估。
When we look at REST implementations in the wild, we frequently see REST misused to naively retrieve object graphs through chatty interactions between client and server. Facebook's GraphQL is an interesting alternative to REST that might be a better approach for this very common use case. As a protocol for remotely retrieving object graphs, GraphQL has received enormous attention recently. One of GraphQL's most interesting features is its consumer-oriented nature: The structure of a response is driven entirely by the client, not the server. This decouples the consumer and forces the server to obey Postel's law. Client implementations are now available in many programming languages, but we have seen a flurry of interest of Facebook's Relay, a JavaScript framework that was designed to support the React.js stateless component model.