- Hands-On Full-Stack Web Development with GraphQL and React
- Sebastian Grebe
- 276字
- 2021-07-02 13:20:47
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.
- Mastering Node.js(Second Edition)
- Mastering Machine Learning for Penetration Testing
- 從區(qū)塊鏈到Web3:構建未來互聯(lián)網(wǎng)生態(tài)
- JBoss EAP6 High Availability
- 物聯(lián)網(wǎng)與無線傳感器網(wǎng)絡
- 網(wǎng)管員必讀:網(wǎng)絡管理(第2版)
- VMware NSX網(wǎng)絡虛擬化入門
- Learning Windows 8 Game Development
- React Cookbook
- Web用戶查詢日志挖掘與應用
- 精通SEO:100%網(wǎng)站流量提升密碼
- 區(qū)塊鏈社區(qū)運營手冊
- 黑客與反黑工具使用詳解
- Migrating to Drupal7
- ElasticSearch Server