官术网_书友最值得收藏!

Using databases in GraphQL

GraphQL is a protocol for sending and receiving data. Apollo is one of the many libraries that you can use to implement that protocol. Neither GraphQL (in its specifications) nor Apollo work directly on the data layer. Where the data that you put into your response comes from, and where the data that you send with your request is saved, are up to the user to decide.

This logic indicates that the database and the services that you use do not matter to Apollo, as long as the data that you respond with matches the GraphQL schema.

As we are living in the Node.js ecosystem in this project and book, it would be fitting to use MongoDB. MongoDB offers a great client library for Node.js, and also uses JavaScript as its native choice of language for interactions and querying.

The general alternative to a database system like MongoDB is a typical SQL server with proven stability and enormous spreading. One case that I encounter more and more frequently involves systems and applications relying on older code bases and databases that need upgrades. A great way to accomplish this is to get an over-layering API level with GraphQL. In this scenario, the GraphQL server receives all requests, and, one by one, you can replace the existing code bases that the GraphQL server relies on. In these cases, it is helpful that GraphQL is database agnostic.

In this book, we will use SQL via Sequelize in order to see this feature in a real-world use case. For future purposes, it will also help you to handle problems with existing SQL-based systems.

主站蜘蛛池模板: 仁布县| 桓仁| 苏州市| 赣州市| 榆社县| 台南市| 弥渡县| 谷城县| 犍为县| 卫辉市| 孟连| 临夏县| 林西县| 佛坪县| 丹阳市| 蒲城县| 浦东新区| 通河县| 丰顺县| 罗城| 土默特右旗| 白水县| 新绛县| 浙江省| 隆化县| 淳安县| 阿拉善左旗| 扎鲁特旗| 奉化市| 镶黄旗| 永和县| 辽源市| 扬州市| 河北省| 莎车县| 榆中县| 丹巴县| 文昌市| 忻城县| 青岛市| 呼伦贝尔市|