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. LINUX运维实战案例之文件已删除但空间不释放问题的分析与解决办法

    1.错误现象 运维的监控系统发来通知,报告一台服务器空间满了,登陆服务器查看,根分区确实没有空间了,如下图所示: 这里首先说明一下服务器的一些删除策略,由于Linux没有回收站功能,我们的线上服务器所 ...

  2. day 2 常用快捷键

    tab命令或路径补全**,linux里最有用的快捷键,如果tab不到路径或命令,就代表没有这个路径或者命令,还有可能是权限不对. ctrl+c :终止当前任务命令或程序. ctrl+d 退出当前用户环 ...

  3. WebRequest 访问 https

    参考代码: 1: [TestMethod] 2: public void TestHttps() 3: { 4: var req =(HttpWebRequest) System.Net.WebReq ...

  4. 网页中显示pdf

    1.<embed width="800" height="600" src="test_pdf.pdf"> </embed ...

  5. 工欲善其事必先利其器——dreamweaver

    1.内置了一个webkit内核,所以实时视图与chrome浏览器效果一样. 2.DW中主浏览器的快捷键是f12,所以可以f12快速打开浏览器. 3.DW中首选项无法恢复到默认值. 4.有用首选项 5. ...

  6. [转]UpdatePanel的用法详解

    本文转自:http://www.cnblogs.com/shangxia/articles/2281782.html 今天用做日历显示本月的考勤记录,用到了UpdatePanel控件,才发现对这个控件 ...

  7. [转]backbone.js 示例 todos

    本文转自:http://www.css88.com/doc/backbone/examples/todos/index.html <!DOCTYPE html> <html lang ...

  8. selenium结合sikuliX操作Flash网页

    sikuli的官网地址:http://www.sikuli.org 首先下载sikuliX的jar包:https://launchpad.net/sikuli/sikulix/1.1.0 java-d ...

  9. Qt基础之开发环境部署

    将 Qt 5.6 集成至 VS2015 摘要: 由于VS2015不再支持addin,所以要用其他手段. 这里给出64位系统下的安装步骤,32位类似. 一.安装VS2015 过程略.值得注意的是要选择需 ...

  10. java 27 - 3 反射之 通过反射获取构造方法并使用

    类 Constructor<T>:提供关于类的单个构造方法的信息以及对它的访问权限. 通过反射的方法获取构造方法并使用  ps:先忽略泛型 A.1:获取构造方法的数组: public Co ...