当前位置: 首页 > 软件库 > 大数据 > 数据查询 >

graphql-perl

GraphQL in Perl 5
授权协议 Readme
开发语言 Java
所属分类 大数据、 数据查询
软件类型 开源软件
地区 不详
投 递 者 佘缪文
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

NAME

GraphQL - Perl implementation of GraphQL

PROJECT STATUS

OS Build status
Linux

SYNOPSIS

use GraphQL::Schema;
use GraphQL::Type::Object;
use GraphQL::Type::Scalar qw($String);
use GraphQL::Execution qw(execute);

my $schema = GraphQL::Schema->from_doc(<<'EOF');
type Query {
  helloWorld: String
}
EOF
post '/graphql' => sub {
  send_as JSON => execute(
    $schema,
    body_parameters->{query},
    { helloWorld => 'Hello world!' },
    undef,
    body_parameters->{variables},
    body_parameters->{operationName},
    undef,
  );
};

The above is from the sample Dancer 2 applet.

DESCRIPTION

This module is a port of the GraphQL reference implementation,graphql-js, to Perl 5.

It now supports Promises, allowing asynchronous operation. SeeMojolicious::Plugin::GraphQL for an example of how to take advantageof this.

As of 0.39, supports GraphQL subscriptions.

See GraphQL::Type for description of how to create GraphQL types.

Introduction to GraphQL

GraphQL is a technology that lets clients talk to APIs via a singleendpoint, which acts as a single "source of the truth". This means clientsdo not need to seek the whole picture from several APIs. Additionally,it makes this efficient in network traffic, time, and programming effort:

  • Network traffic

    The request asks for exactly what it wants, which it gets, and nomore. No wasted traffic.

  • Time

    It gets all the things it needs in one go, including any connectedresources, so it does not need to make several requests to fill itsinformation requirement.

  • Programming effort

    With "fragments" that can be attached to user-interface components,keeping track of what information a whole page needs to request can beautomated. See Relay orApollo for more on this.

Basic concepts

GraphQL implements a system featuring a schema,which features various classes of types, some of whichare objects. Special objects provide the rootsof queries (mandatory), and mutations and subscriptions (both optional).

Objects have fields, each of which can be specified to take arguments,and which have a return type. These are effectively the properties and/ormethods on the type. If they return an object, then a query can specifysubfields of that object, and so on - as alluded to in the "time-saving"point above.

For more, see the JavaScript tutorial in "SEE ALSO".

Hooking your system up to GraphQL

You will need to decide how to model your system in GraphQL terms. Thiswill involve deciding on what output object typesyou have, what fields they have, and what arguments and return-typesthose fields have.

Additionally, you will need to design mutations if you want to be ableto update/create/delete data. This requires some thought for return types,to ensure you can get all the information you need to proceed to avoidextra round-trips.

The easiest way to achieve these things is to make aGraphQL::Plugin::Convert subclass, to encapsulate the specifics ofyour system. See the documentation for further information.

Finally, you should consider whether you need "subscriptions". Theseare designed to hook into WebSockets. Apollo has a JavaScriptmodule for this.

Specifying types and fields is straightforward. See thedocument for how to make resolvers.

DEBUGGING

To debug, set environment variable GRAPHQL_DEBUG to a true value.

EXPORT

None yet.

SEE ALSO

SQL::Translator::Producer::GraphQL - produce GraphQL schemas from a DBIx::Class::Schema (or in fact any SQL database)

GraphQL::Plugin::Convert::DBIC - produce working GraphQL schema froma DBIx::Class::Schema

GraphQL::Plugin::Convert::OpenAPI - produce working GraphQL schemafrom an OpenAPI specification

Sample Mojolicious OpenAPI to GraphQL applet

Sample Dancer 2 applet

Sample Mojolicious applet

Dancer2::Plugin::GraphQL

Mojolicious::Plugin::GraphQL

http://facebook.github.io/graphql/ - GraphQL specification

http://graphql.org/graphql-js/ - Tutorial on the JavaScript version,highly recommended.Translation tographql-perl.

AUTHOR

Ed J, <etj at cpan.org>

BUGS

Please report any bugs or feature requests onhttps://github.com/graphql-perl/graphql-perl/issues.

Or, if you prefer email and/or RT: to bug-graphql at rt.cpan.org, or through the web interface athttp://rt.cpan.org/NoAuth/ReportBug.html?Queue=GraphQL. I will benotified, and then you'll automatically be notified of progress on yourbug as I make changes.

ACKNOWLEDGEMENTS

The creation of this work has been sponsored by Perl Careers:https://perl.careers/.

Artur Khabibullin <rtkh at cpan.org> contributed valuable portsof the JavaScript tests.

The creation of the subscriptions functionality in this work has beensponsored by Sanctus.app: https://sanctus.app.

LICENSE AND COPYRIGHT

Copyright 2017 Ed J.

This program is free software; you can redistribute it and/or modify itunder the terms of the the Artistic License (2.0). You may obtain acopy of the full license at:

http://www.perlfoundation.org/artistic_license_2_0

  •   今天不忙,就装了一个postgresql来玩玩。 按着指南安装很简单。     后来我需要用程序测试一下,我的程序跟postgresql在同一台机器上。   另外DBD::Pg也要安装一下(这个模块对version.pm有依赖,所以需要安装version.pm)。虽然我已经有了DBI。     之后简单测试了一下,好用:   use strict; use warnings; use Data

 相关资料
  • 快速开始 GraphQL 是一种用于 API 的查询语言。这是 GraphQL 和 REST 之间一个很好的比较 (译者注: GraphQL 替代 REST 是必然趋势)。在这组文章中, 我们不会解释什幺是 GraphQL, 而是演示如何使用 @nestjs/GraphQL 模块。 GraphQLModule 只不过是 Apollo 服务器的包装器。我们没有造轮子, 而是提供一个现成的模块, 这让

  • GraphQL 既是一种用于 API 的查询语言也是一个满足你数据查询的运行时。 GraphQL 对你的 API 中的数据提供了一套易于理解的完整描述,使得客户端能够准确地获得它需要的数据,而且没有任何冗余,也让 API 更容易地随着时间推移而演进,还能用于构建强大的开发者工具。 向你的 API 发出一个 GraphQL 请求就能准确获得你想要的数据,不多不少。 GraphQL 查询总是返回可预测

  • Graphql editor 是一款 Graphql 的可视化编辑器和 IDE,帮助用户更容易理解 GraphQL 模式,通过使用可视化块系统创建模式。GraphQL Editor 将把它们转化为代码。通过 GraphQL Editor,用户可以在不写任何代码的情况下创建可视化的图表,或者以一种很好的方式呈现其模式。 GraphQL View Code Editor View Hierarchy View

  • GraphQL CLI Help us to improve new GraphQL CLI. Check out the new structure and commands below!Feel free to contact us in Discord channel. We would love to hear your feedback. Features Helpful command

  • Fullstack GraphQL Simple Demo Application API built with Node + Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with React + Redux. Written in ES6 using Babel

  • Hasura GraphQL Engine Hasura is an open source product that accelerates API development by 10x by giving you GraphQL or REST APIs with built in authorization on your data, instantly. Read more at hasu

  • 这是利用Koa + GraphQL + Apollo-Server实现的,学生信息增、删、改、查的栗子 本栗子将搭配Koa实现一个GraphQL查询,逐步从简单Kao服务、到Mongodb的数据插入查询、再到GraphQL的使用,让大家快速看到: 搭建Koa搭建一个后台项目 后台路由简单处理方式 利用Mongoose简单操作Mongodb的增、删、改、查 掌握Apollo-Server简单操作数据

  • GraphQL Ruby 是 GraphQL 的一个 Ruby 实现。 Website API Documentation Newsletter 安装: # Gemfilegem 'graphql' $ bundle install 旨在: 实现 GraphQL 规范并支持一个 Relay 前端 在可能的情况下,提供与参考实现相似的习惯性的、简单的 Ruby API 支持 Ruby on Rails 和 Relay