Introduction to GraphQL

 GraphQL介绍
Learn about GraphQL, how it works, and how to use it in this series of articles. Looking for documentation on how to build a GraphQL service? There are libraries to help you implement GraphQL in many different languages.
学习GraphQL,学习他如何工作,以及在这一系列的文章中如何使用它。寻找如何建立一个GraphQL服务的文档?这里有一个库可以帮助你使用不同的语言去实现GraphQL.
GraphQL is a query language for your API, and a server-side runtime for executing queries by using a type system you define for your data. GraphQL isn't tied to any specific database or storage engine and is instead backed by your existing code and data.
GraphQ是一个为你自己API定义的一种查询语言,是一个使用你自己定义的系统类型在服务器端运行时执行的查询语言。GraphQl不与任何一个特定的数据库或存储引擎相关,相反它是与你已经存在的代码和数据相关。
A GraphQL service is created by defining types and fields on those types, then providing functions for each field on each type. For example, a GraphQL service that tells us who the logged in user is (me) as well as that User's name might look something like this:
一个GraphQL服务是根据特定的type和fields创建的,然后为每一个type的每一个field提供函数。例如,一个像这样的GraphQl服务可以告诉我们登录的用户是谁以及用户的姓名:
type Query {
me: User
} type User {
id: ID
name: String
}

Along with functions for each field on each type:

以及每一个字段的每个类型的函数:

 function Query_me(request) {
return request.auth.user;
} function User_name(user) {
return user.getName();
}

Once a GraphQL service is running (typically at a URL on a web service), it can be sent GraphQL queries to validate and execute. A received query is first checked to ensure it only refers to the types and fields defined, then runs the provided functions to produce a result.

一旦一个GraplQl服务在运行(尤其是在一个web服务器上的URL地址),它将会发送GraphQL查询去验证和执行。一个接收到的查询首先去检查并确保它仅仅是引用定义的type和fields,之后再运行提供的函数去生成一个结果。

For example the query:

例如:

{
me {
name
}
}

Could produce the JSON result:

将产生的JSON结果:

{
"me": {
"name": "Luke Skywalker"
}
}

Learn more about GraphQL: the query language, type system, how the GraphQL service works, and as well as best practices for using GraphQL to solve common problems in the articles written in this section.

学习更多的关于GraphQl:查询语言,type系统,GraphQl服务如何工作,以及使用GraphQl去解决这个文章中的通用问题的最佳实践。

Graphql介绍(Introduction to GraphQL)的更多相关文章

  1. GraphQL介绍&使用nestjs构建GraphQL查询服务

    GraphQL介绍&使用nestjs构建GraphQL查询服务(文章底部附demo地址) GraphQL一种用为你 API 而生的查询语言.出自于Facebook,GraphQL非常易懂,直接 ...

  2. ASP.NET Core中使用GraphQL - 第九章 在GraphQL中处理多对多关系

    ASP.NET Core中使用GraphQL ASP.NET Core中使用GraphQL - 第一章 Hello World ASP.NET Core中使用GraphQL - 第二章 中间件 ASP ...

  3. iOS: 属性列表介绍 Introduction to Property Lists

    iOS: 属性列表介绍 Introduction to Property Lists 从本质上说, 属性列表就是苹果的对象数据序列化与反序列化方式 属性列表使用几种数据类型把数据组织为键值表和值表 P ...

  4. 【线性代数】6-1:特征值介绍(Introduction to Eigenvalues)

    title: [线性代数]6-1:特征值介绍(Introduction to Eigenvalues) categories: Mathematic Linear Algebra keywords: ...

  5. ASP.NET Core中使用GraphQL - 第八章 在GraphQL中处理一对多关系

    ASP.NET Core中使用GraphQL - 目录 ASP.NET Core中使用GraphQL - 第一章 Hello World ASP.NET Core中使用GraphQL - 第二章 中间 ...

  6. [GraphQL] Query GraphQL Interface Types in GraphQL Playground

    Interfaces are similar to Unions in that they provide a mechanism for dealing with different types o ...

  7. GraphQL 01--- GraphQL 介绍及资源总结

    作为一位web开发人员,在使用REST API的时候,是否遇到过这样的问题: 1.调用一个API的时候,总是会返回一些不需要的信息. 2. 对于一个资源的调用,如果想获取到更多的信息,可能需要发送多次 ...

  8. 使用Hot Chocolate和.NET 6构建GraphQL应用(1)——GraphQL及示例项目介绍

    系列导航 使用Hot Chocolate和.NET 6构建GraphQL应用文章索引 前言 这篇文章是这个系列的第一篇,我们会简单地讨论一下GraphQL,然后介绍一下这个系列将会使用的示例项目. 关 ...

  9. 5个用/不用GraphQL的理由

    我在如何使用Gatsby建立博客 / How to build a blog with Gatsby这篇文章中提过GraphQL在Gatsby中的应用.总的来讲,它是一个新潮的技术,在适宜的使用场景威 ...

随机推荐

  1. Javascript parseFloat内部解析规则

    这是由小习发的一个问题引起的讨论,结束后大家各自加深了多parseFloat的理解. 如下 16进制数0x10使用parseFloat转成数字,结果为0.潜意识期望的结果是16. 有人说脑残,16进制 ...

  2. java中的io系统详解 - ilibaba的专栏 - 博客频道 - CSDN.NET

    java中的io系统详解 - ilibaba的专栏 - 博客频道 - CSDN.NET 亲,“社区之星”已经一周岁了!      社区福利快来领取免费参加MDCC大会机会哦    Tag功能介绍—我们 ...

  3. Android SDK和N多Android开发资源

    开发资源 本文收集整理Android开发需要的Android SDK.工具.Android开发教程.Android设计规范,免费的设计素材等. 欢迎大家推荐自己在Android开发过程中用的好用的工具 ...

  4. 这几天在搞UNITY3D,感觉回到了AS2

    这几天在搞UNITY3D,感觉回到了AS2 代码没有MAIN, 代码在屏幕上,和元件绑定

  5. jmeter 与 json

    1.添加一个 http信息头管理: Add new value for Name = “Content-Type” and value = “application/json” (without qu ...

  6. apache网站访问缓慢的处理记录

    朋友在阿里云上开通了一台ubuntu服务器(2G内存,2核CPU),用apache搭建了一个公众号网站.网站初期,他没有做相应的优化,在后续公众号推广活动时,网站并发突增,访问十分缓慢.登陆服务器,具 ...

  7. 在Java代码中使用pdfBox将PDF转换为图片

    生成图片 // 生成图片 PDDocument pd = PDDocument.load(new File(filePath)); PDFRenderer pdfRenderer = new PDFR ...

  8. Win10删除 6个多余文件夹

    下面附上注册表地址,HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace ...

  9. CSS IE6/7/8, Firefox, Safari, Chrome, Opera Hack使用简要归纳(转)

    网上有很多关于IE6/7/8, Firefox, Safari, Chrome, Opera CSS Hack的文章,但我觉得太过繁杂,要不给出一张看也看不懂的CSS Hack归纳表,要不就是给出一大 ...

  10. SharePoint Foundation 2013 with SP1

    终于支持在 Windows Server 2012 R2 上安装了. 下载 另外,还有一个针对SharePoint Foundation 2013的重要更新.可以在安装SP1之前或之后安装. Micr ...