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. JQuery中的extend函数

    1.jQuery.fn.extend(object) 扩展 jQuery 元素集来提供新的方法(通常用来制作插件). 例如:增加两个插件方法. jQuery.fn.extend({ check: fu ...

  2. [Top-Down Approach]My First C/S Program [Python]

    These days I was learning from Computer Networking --A Top-Down Approach by Kurose Ross. I modified ...

  3. 初步了解Entity Framework

    来源:http://www.cnblogs.com/Wayou/archive/2012/09/20/EF_CodeFirst.html Entity Framework的全称是ADO.NET Ent ...

  4. 三维网格形变算法(Gradient-Based Deformation)

    将三角网格上的顶点坐标(x,y,z)看作3个独立的标量场,那么网格上每个三角片都存在3个独立的梯度场.该梯度场是网格的微分属性,相当于网格的特征,在形变过程中随控制点集的移动而变化.那么当用户拖拽网格 ...

  5. AC日记——接龙游戏 codevs 1051

    1051 接龙游戏  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 钻石 Diamond       题目描述 Description 给出了N个单词,已经按长度排好了序.如果 ...

  6. ASP.NET MVC

    ASP.NET MVC 就是根据 Model 2 模式设计的.对于 HTTP 请求的拦截以实现对目标 Controller 和 Action 的解析是通过一个自定义 Http Module 来实现的, ...

  7. FMS 客户端带宽计算、带宽限制

    FMS 客户端带宽计算.带宽限制 1. 带宽计算 FMS内置了带宽检测的特性(被称作"native bandwidth detection"),要进行带宽检测,客户端只要在成功连接 ...

  8. [No00003F]richtextbox实现拖放

    namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { Initialize ...

  9. url编码base编码解码十六进制

    0x25346425353425343525333525343325366125343525373725346425353125366625373825346425343425363725346225 ...

  10. bzoj1036 [ZJOI2008]树的统计Count

    1036: [ZJOI2008]树的统计Count Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 12646  Solved: 5085 [Subm ...