Graphql介绍(Introduction to GraphQL)

Posted 霓裳梦竹

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Graphql介绍(Introduction to GraphQL)相关的知识,希望对你有一定的参考价值。

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:

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

1 function Query_me(request) {
2   return request.auth.user;
3 }
4 
5 function User_name(user) {
6   return user.getName();
7 }

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)的主要内容,如果未能解决你的问题,请参考以下文章

条件随机场介绍—— An Introduction to Conditional Random Fields

Introduction to Logistic Regression(逻辑回归介绍)

Introduction to RBM 总结

译提升树算法的介绍(Introduction to Boosted Trees)

条件随机场介绍—— An Introduction to Conditional Random Fields

[An Introduction to GCC 学习笔记] 01 介绍GCC发展历史