美文网首页
【中台技术】之GraphQL-一种用于 API 的查询语言

【中台技术】之GraphQL-一种用于 API 的查询语言

作者: WXL_JIANSHU | 来源:发表于2021-01-20 12:14 被阅读0次

    1、简介

    GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时。 GraphQL 对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,而且没有任何冗余,也让 API 更容易地随着时间推移而演进,还能用于构建强大的开发者工具。

    2、官网

    https://graphql.org/
    https://graphql.cn/

    3、特性

    • Ask for what you need,get exactly that.

    Send a GraphQL query to your API and get exactly what you need, nothing more and nothing less. GraphQL queries always return predictable results. Apps using GraphQL are fast and stable because they control the data they get, not the server.

    • Get many resources,in a single request.

    GraphQL queries access not just the properties of one resource but also smoothly follow references between them. While typical REST APIs require loading from multiple URLs, GraphQL APIs get all the data your app needs in a single request. Apps using GraphQL can be quick even on slow mobile network connections.

    • Describe what’s possible,with a type system.

    GraphQL APIs are organized in terms of types and fields, not endpoints. Access the full capabilities of your data from a single endpoint. GraphQL uses types to ensure Apps only ask for what’s possible and provide clear and helpful errors. Apps can use types to avoid writing manual parsing code.

    • Move faster with,powerful developer tools.

    Know exactly what data you can request from your API without leaving your editor, highlight potential issues before sending a query, and take advantage of improved code intelligence. GraphQL makes it easy to build powerful tools like GraphiQL by leveraging your API’s type system.

    • Evolve your API,without versions.

    Add new fields and types to your GraphQL API without impacting existing queries. Aging fields can be deprecated and hidden from tools. By using a single evolving version, GraphQL APIs give apps continuous access to new features and encourage cleaner, more maintainable server code.

    • Bring your own,data and code.

    GraphQL creates a uniform API across your entire application without being limited by a specific storage engine. Write GraphQL APIs that leverage your existing data and code with GraphQL engines available in many languages. You provide functions for each field in the type system, and GraphQL calls them with optimal concurrency.

    4、应用案例

    相关文章

      网友评论

          本文标题:【中台技术】之GraphQL-一种用于 API 的查询语言

          本文链接:https://www.haomeiwen.com/subject/vrckzktx.html