首页 > 代码库 > Graphql介绍(Introduction to GraphQL)
Graphql介绍(Introduction to GraphQL)
Introduction to GraphQL
me
) as well as that User‘s name might look something like this: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)