All Projects β†’ CurtTilmes β†’ Perl6-GraphQL

CurtTilmes / Perl6-GraphQL

Licence: other
Perl 6 implementation of GraphQL

Programming Languages

perl
6916 projects
Makefile
30231 projects

Projects that are alternatives of or similar to Perl6-GraphQL

ugql
πŸš€GraphQL.js over HTTP with uWebSockets.js
Stars: ✭ 27 (+42.11%)
Mutual labels:  graphql-server
bramble
The Movio GraphQL Gateway
Stars: ✭ 423 (+2126.32%)
Mutual labels:  graphql-server
graphyne
⚑ Lightning-fast JavaScript GraphQL Server ⚑
Stars: ✭ 18 (-5.26%)
Mutual labels:  graphql-server
express-graphql-boilerplate-hmr
Boilerplate for Express + GraphQL with HMR
Stars: ✭ 15 (-21.05%)
Mutual labels:  graphql-server
dev-feed
Flutter-based mobile app displaying a list of daily curated content from top engineering blogs and articles. Backed by a GraphQL-based API written in Kotlin..
Stars: ✭ 20 (+5.26%)
Mutual labels:  graphql-server
finch-sangria
A simple wrapper for using Sangria from within Finch.
Stars: ✭ 33 (+73.68%)
Mutual labels:  graphql-server
Heighliner
A GraphQL Server for NewSpring Web
Stars: ✭ 13 (-31.58%)
Mutual labels:  graphql-server
ngraphql
GraphQL .NET Server and Client
Stars: ✭ 26 (+36.84%)
Mutual labels:  graphql-server
docker-api-graphql
GraphQL API wrapper around the Docker Remote API. SpringBoot-based app, written in Kotlin
Stars: ✭ 13 (-31.58%)
Mutual labels:  graphql-server
koa-server
πŸ—„οΈ GraphQL Back-end Server with Relay, Koa, MongoDB and Mongoose
Stars: ✭ 31 (+63.16%)
Mutual labels:  graphql-server
graphql-bench
A super simple tool to benchmark GraphQL queries
Stars: ✭ 222 (+1068.42%)
Mutual labels:  graphql-server
apollo-express-ts-server-boilerplate
No description or website provided.
Stars: ✭ 29 (+52.63%)
Mutual labels:  graphql-server
graphql-cli-generate-fragments
Generate Fragments for Graphql Schemas
Stars: ✭ 43 (+126.32%)
Mutual labels:  graphql-server
graphql-query-whitelist
GraphQL query whitelisting middleware
Stars: ✭ 17 (-10.53%)
Mutual labels:  graphql-server
graphql-boilerplate
πŸ’’ Example usage of GraphQL without any third-party packages.
Stars: ✭ 45 (+136.84%)
Mutual labels:  graphql-server
kingdom-python-server
Modular, cohesive, transparent and fast web server template
Stars: ✭ 20 (+5.26%)
Mutual labels:  graphql-server
graphql-modules-app
TypeScripted Apollo GraphQL Server using modules and a NextJS frontend utilising React modules with Apollo hooks. All bundled with a lot of dev friendly tools in a lerna setup..
Stars: ✭ 39 (+105.26%)
Mutual labels:  graphql-server
fullstack-graphql-angular
Simple Fullstack GraphQL Application with Angular CLI + Redux. API built with Typescript + Express + GraphQL + Sequelize (supports MySQL, Postgres, Sqlite and MSSQL). WebApp built with Angular CLI + Redux + Async Middleware to access the API.
Stars: ✭ 67 (+252.63%)
Mutual labels:  graphql-server
graphscript
A GraphQL Boilerplate with Typescript and TypeORM ⚑
Stars: ✭ 27 (+42.11%)
Mutual labels:  graphql-server
graphql-spotify
GraphQL Schema And Resolvers For Spotify Web API
Stars: ✭ 55 (+189.47%)
Mutual labels:  graphql-server

Perl 6 GraphQL

Build Status

A Perl 6 implementation of the GraphQL standard. GraphQL is a query language for APIs originally created by Facebook.

Intro

Before we get into all the details, here's the Perl 6 GraphQL "Hello World" hello.pl

use GraphQL;
use GraphQL::Server;

class Query
{
    method hello(--> Str) { 'Hello World' }
}

my $schema = GraphQL::Schema.new(Query);

GraphQL-Server($schema);

You can run this with a GraphQL query on the command line:

$ perl6 hello.pl --help
Usage:
  hello.pl <query>
  hello.pl [--filename=<Str>]
  hello.pl [--port=<Int>]

$ perl6 hello.pl '{hello}'
{
  "data": {
    "hello": "Hello World"
  }
}

You can even ask for information about the schema and types:

$ perl6 hello.pl '{ __schema { queryType { name } } }'
{
  "data": {
    "__schema": {
      "queryType": {
        "name": "Query"
      }
    }
  }
}

$ perl6 hello.pl '{ __type(name: "Query") { fields { name type { name }}}}'
{
  "data": {
    "__type": {
      "fields": [
        {
          "name": "hello",
          "type": {
            "name": "String"
          }
        }
      ]
    }
  }
}

Running as a server

That's fine for the command line, but you can also easily wrap GraphQL into a web server to expose that API to external clients. GraphQL::Server uses the Perl 6 web framework Bailador to do that:

$ ./hello.pl
Entering the development dance floor: http://0.0.0.0:3000
[2016-12-21T13:02:38Z] Started HTTP server.

The server takes any GraphQL query sent with HTTP POST to /graphql, executes it against the GraphQL Schema, and returns the result in JSON.

There is one additional feature. If it receives a GET request to "/graphql", it sends back the GraphiQL graphical interactive in-browser GraphQL IDE.

You can use that to explore the schema (though the Hello World schema is very simple, that won't take long), and interactively construct and execute GraphQL queries.

Embedding in a Cro server

As an alternative to Bailador, you can use Cro::HTTP::Router::GraphQL to embed GraphQL into Cro HTTP routes:

use GraphQL;
use Cro::HTTP::Router::GraphQL;
use Cro::HTTP::Router;
use Cro::HTTP::Server;

class Query
{
    method hello(--> Str) { 'Hello World' }
}

my $schema = GraphQL::Schema.new(Query);

my Cro::Service $hello = Cro::HTTP::Server.new:
    :host<localhost>, :port<10000>,
    application => route
    {
        get -> { redirect '/graphql' }

        get -> 'graphql' { graphiql }

        post -> 'graphql' { graphql($schema) }
    }

$hello.start;

react whenever signal(SIGINT) { $hello.stop; exit; }

You can mix/match with other routes you want your server to handle.

There is also a CroX::HTTP::Transform::GraphQL you can easily delegate to from Cro routes:

route {
    delegate graphql => CroX::HTTP::Transform::GraphQL.new(:$schema, :graphiql);
}

Pass in your GraphQL schema, and optional :graphiql to enable GraphiQL support on an http GET.

CroX::HTTP::Transform::GraphQL is a Cro::HTTP::Transform that consumes Cro::HTTP::Requests and produces Cro::HTTP::Responses. It is still pretty basic. A planned enhancement is caching parsed GraphQL query documents. (Patches or advice welcome!)

More documentation

See eg/usersexample.md for a more complicated example.

See slides from a presentation about Perl 6 GraphQL at the Philadelphia Perl Mongers.

GraphQL Documentation

Copyright Β© 2017 United States Government as represented by the Administrator of the National Aeronautics and Space Administration. No copyright is claimed in the United States under Title 17, U.S.Code. All Other Rights Reserved.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].