📅  最后修改于: 2020-10-25 05:06:31             🧑  作者: Mango
本章讨论了不同的GraphQL组件及其相互通信的方式。整个应用程序组件可以区分如下-
GraphQL服务器构成服务器端的核心组件,并允许解析来自GraphQL客户端应用程序的查询。 Apollo Server是GraphQL规范的最常用实现。其他服务器编程组件包括以下内容-
Sr.No. | Server Essentials & Description |
---|---|
1 |
Schema A GraphQL schema is at the center of any GraphQL server implementation and describes the functionality available to the clients which connect to it. |
2 |
Query A GraphQL query is the client application request to retrieve data from database or legacy API’s. |
3 |
Resolver Resolvers provide the instructions for turning a GraphQL operation into data. They resolve the query to data by defining resolver functions. |
下面给出的是客户端组件-
Sr.No. | Tool & Description |
---|---|
1 |
GraphiQL Browser based interface for editing and testing GraphQL queries and mutations. |
2 |
ApolloClient Best tool to build GraphQL client applications. Integrates well with all javascript front-end. |
下图显示了客户端-服务器体系结构。 Web服务器基于NodeJ和Express框架构建。 ReactJS应用程序(使用Apollo客户端库构建)或GraphiQL浏览器应用程序向Apollo GraphQL服务器发出请求。该查询将根据服务器中定义的模式进行解析和验证。如果请求模式通过验证,则将执行关联的解析器功能。解析器将包含用于从API或数据库中获取数据的代码。