zoukankan      html  css  js  c++  java
  • 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去解决这个文章中的通用问题的最佳实践。

  • 相关阅读:
    C#Ref和Out作用于引用对象时的理解
    Docker-.Net Core部署
    微服务-基于Grpc的进程通信-Protobuf-net.Grpc(4-3)
    微服务-基于Grpc的进程通信-Grpc服务注册与发现 (4-2)
    微服务-基于Grpc的进程通信-简单使用(4-1)
    ELK-Windows下系统安装(1)
    Visual Studio 2019中如何使用Git
    VS2019下载速度快完成时突然变得极慢
    Swagger 发布服务器导出Excel失败,本地导出没问题
    发布到服务器后导出Excel失败
  • 原文地址:https://www.cnblogs.com/dream-to-pku/p/5910666.html
Copyright © 2011-2022 走看看