常规
¥General
GraphQL 是前端还是后端?
¥Is GraphQL frontend or backend?
两者兼而有之。GraphQL 指定了如何使用 在客户端和服务器之间交换信息。这包括服务器如何指示 有哪些数据和操作可用、客户端应该如何 格式化请求、服务器应该如何 执行这些查询 以及客户端将做什么 响应接收。
¥Both. GraphQL specifies how you can exchange information between client and server. This includes how the server can indicate what data and operations are available, how the client should format requests, how the server should execute these queries, and what the client will receive in response.
GraphQL 是否使用 HTTP?
¥Does GraphQL use HTTP?
是的,GraphQL 通常通过 HTTP 提供。这在很大程度上是由于 HTTP 协议在我们行业中的普及程度。但通过创建 单个 HTTP 请求 来尝试 GraphQL 会有所帮助。有关设置通过 HTTP 运行的 GraphQL 服务器的指南可在我们的 通过 HTTP 提供服务 文档中找到。
¥Yes, GraphQL is typically served over HTTP. This is largely due to how pervasive the HTTP protocol is in our industry. But it helps that you can try out GraphQL by creating a single HTTP request. Guidelines for setting up a GraphQL server to operate over HTTP are available in our Serving over HTTP documentation.
虽然 HTTP 是客户端-服务器协议的最常见选择,但它并不是唯一的选择。GraphQL 与传输层无关。因此,例如,你可以使用 WebSockets 进行 GraphQL 订阅,而不是使用 HTTP 来使用实时数据。
¥While HTTP is the most common choice for client-server protocol, it’s not the only one. GraphQL is agnostic to the transport layer. So, for example, you could use WebSockets for GraphQL subscriptions instead of HTTP to consume realtime data.
GraphQL 如何影响我的产品性能?
¥How does GraphQL affect my product’s performance?
在典型的 GraphQL 后端,每种类型的每个字段都有一个专注的、单一用途的函数来解析该值。此外,GraphQL 将该逻辑移至服务器 不是尝试在客户端处理数据批处理。因此,有一些固有的性能优势。最小化过度获取和制作 减少与服务器的往返次数 是其中两个。
¥On a typical GraphQL backend, every field on every type has a focused, single-purpose function for resolving that value. Also, instead of trying to handle data batching on the client, GraphQL moves that logic to the server. As a result, there are some inherent performance benefits. Minimizing over-fetching and making fewer roundtrips to the server are two of them.
在构建 GraphQL 实现时,应考虑其他性能因素。例如,GraphQL 服务可能“健谈”并重复从数据库加载数据。这通常由 实现批处理技术 或 使用 DataLoader 等工具 解决。
¥Other performance factors should be considered when building out your GraphQL implementation. For example, it’s possible for a GraphQL service to be ‘chatty’ and repeatedly load data from your database. This is commonly solved by implementing a batching technique or utilizing a tool like DataLoader.
什么是 GraphQL 客户端,我为什么要使用它?
¥What is a GraphQL client and why would I use one?
GraphQL 客户端可以帮助你处理 查询,变更, 和 subscriptions 到 GraphQL 服务器。它们使用 GraphQL API 的底层结构来自动化某些流程。这包括批处理、UI 更新、构建时结构验证等。
¥GraphQL clients can help you handle queries, mutations, and subscriptions to a GraphQL server. They use the underlying structure of a GraphQL API to automate certain processes. This includes batching, UI updates, build-time schema validation, and more.
我们的 代码页 上提供了各种语言的 GraphQL 客户端列表。还有一个关于如何使用 GraphQL 的 深入解释它们的好处。
¥A list of GraphQL clients in various languages is available on our Code page. There’s also an in-depth explanation of their benefits on How To GraphQL.
不过,你不需要特定的客户端来使用 GraphQL。你可能希望从 使用常规 HTTP 客户端发布 GraphQL 结果 开始。然后随着应用的复杂性增加,稍后切换到针对 GraphQL 优化的客户端。
¥You don’t need a specific client to work with GraphQL, though. You might want to start out by issuing GraphQL results with a regular HTTP client. Then later switch to a GraphQL-optimized client as your application grows in complexity.
GraphQL 会取代 ORM 吗?
¥Does GraphQL replace ORMs?
不,GraphQL 是一种通常用于远程客户端-服务器通信的规范。它是 与使用的数据源无关,没有实现对象关系映射技术。但有专门为 GraphQL 构建的 ORM。其中一些列在 我们的代码页面的服务部分 下。
¥No, GraphQL is a specification typically used for remote client-server communications. It’s agnostic to the data source(s) used and doesn’t implement an object-relational mapping technique. But there are ORMs built specifically for GraphQL. A few of those are listed under the Services section of our Code page.
GraphQL 归 Facebook 所有吗?
¥Is GraphQL owned by Facebook?
不,GraphQL 受 GraphQL 基金会 管理。
¥No, GraphQL is governed by the GraphQL Foundation.
也就是说,该规范最初是在 Facebook 和 GraphQL 基金会的 Facebook 是成员 上开发的。你可能会注意到我们的一些 GitHub 存储库 仍然具有 Facebook Inc. 下列出的许可证。我们正在更新这些内容,并且已将主要项目(如 GraphiQL 和 DataLoader)转换为新的版权:“版权所有 (c) 2024 GraphQL 贡献者。”
¥That said, the specification was originally developed at Facebook and Facebook is a member of the GraphQL Foundation. You might notice that some of our GitHub repositories still have the license listed under Facebook Inc. We’re updating those and have already converted major projects, like GraphiQL and DataLoader, to the new copyright: “Copyright (c) 2024 GraphQL Contributors.”
谁是 GraphQL 背后的推手?
¥Who is behind GraphQL?
很多人!GraphQL 规范和所有相关项目 是开源的,因此欢迎任何人使用 contribute。也就是说,存储库背后有一个结构。这是为了解决社区内的冲突并指导技术决策。
¥Many people! The GraphQL specification and all related projects are open source, so anyone is welcome to contribute. That said, there is a structure in place behind the repositories. This exists to resolve conflicts within the community and guiding technical decisions.
GraphQL 基金会 为 GraphQL 提供大部分监督。它由 来自数十家不同公司的代表 组成。
¥The GraphQL Foundation provides most of the oversight for GraphQL. It’s made up of representatives from dozens of different companies.
GraphQL 基金会还管理每月的虚拟 GraphQL 工作组 (WG) 会议。这些会议旨在将常用 GraphQL 库和工具的维护者以及 GraphQL 社区的重要贡献者聚集在一起。WG 会议完全开放。任何人都可以加入 向议程提出项目。
¥There are also monthly virtual GraphQL Working Group (WG) meetings managed by the GraphQL Foundation. These meetings are designed to bring together maintainers of commonly used GraphQL libraries and tools, as well as significant contributors to the GraphQL community. The WG meetings are completely open. Anyone is able to join and propose items to the agenda.
在 2020 年 11 月 WG 会议 中,宣布 GraphQL 将有一个技术指导委员会 (TSC)。更多信息即将发布。
¥In the November 2020 WG meeting, it was announced that GraphQL will have a Technical Steering Committee (TSC) going forward. More on that coming soon.
如果这令人困惑,请不要担心 - 有很多事情要做。要获得更直观、更高级的概述,请查看 GraphQL 概况。
¥If this is confusing, don’t worry - there’s a lot going on. To get a more visual, high-level overview, check out the GraphQL Landscape.
什么是 GraphQL 基金会?
¥What is the GraphQL Foundation?
GraphQL 基金会 是一个中立的基金会,为 GraphQL 提供治理。这包括对开源存储库、资金、事件等的供应商中立监督。它托管在 Linux 基金会 下,由 来自数十家不同公司的代表 组成。我们的想法是,它是 GraphQL 社区的公正和开放之家。
¥The GraphQL Foundation is a neutral foundation that provides governance for GraphQL. This includes vendor-neutral oversight of open-source repositories, funding, events, and more. It’s hosted under the Linux Foundation and consists of representatives from dozens of different companies. The idea is that it’s an impartial and open home for the GraphQL community.
你可以通过访问 foundation.graphql.org 了解更多信息。
¥You can find out more by visiting foundation.graphql.org.