Home

Awesome

Diana.jl

<p align="center"><img src="diana_logo.png" width="25%" ></p> <p align="center"> <strong>A Julia GraphQL client/server implementation.</strong> <br><br> <a href="https://travis-ci.org/neomatrixcode/Diana.jl"><img src="https://travis-ci.org/neomatrixcode/Diana.jl.svg?branch=master"></a> <a href="https://codecov.io/gh/neomatrixcode/Diana.jl"> <img src="https://codecov.io/gh/neomatrixcode/Diana.jl/branch/master/graph/badge.svg" /> </a> <a href="https://neomatrixcode.gitbook.io/diana/"><img src="https://img.shields.io/badge/docs-stable-blue.svg"></a> <a href="https://juliahub.com/ui/Packages/Diana/Lt1mj?t=2"><img src="https://juliahub.com/docs/Diana/deps.svg"></a> <a href="https://juliahub.com/ui/Packages/Diana/Lt1mj"><img src="https://juliahub.com/docs/Diana/version.svg"></a> <a href="https://juliahub.com/ui/Packages/Diana/Lt1mj"><img src="https://juliahub.com/docs/Diana/pkgeval.svg"></a> <a href=""><img src="https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/Diana"></a> <a href="https://raw.githubusercontent.com/neomatrixcode/Diana.jl/master/LICENSE.md"><img src="https://img.shields.io/badge/License-MIT-blue.svg"></a> <a href="https://zenodo.org/badge/latestdoi/97287478"><img src="https://zenodo.org/badge/97287478.svg" alt="DOI"></a> </p>

Contributions welcomed!

This repository is an implementation of a GraphQL server, a query language for API created by Facebook. See more complete documentation at http://graphql.org/

Looking for help? Find resources from the community.

Getting Started

An overview of GraphQL in general is available in the README for the Specification for GraphQL.

This package is intended to help you building GraphQL schemas/types fast and easily.

Installation

Pkg> add Diana
#Release
pkg> add Diana#master
#Development

Examples

Client

query = """
{
  neomatrix{
    nombre
    linkedin
  }
}
"""

r = Queryclient("https://neomatrix.herokuapp.com/graphql",query)
client = GraphQLClient("https://api.graph.cool/simple/v1/movies",auth="Bearer my-jwt-token")

query2 = """
query getMovie(\$title: String!) {
  Movie(title:\$title) {
    releaseDate
    actors {
      name
    }
  }
}
"""
r = client.Query(query2,vars=Dict("title" => "Inception"))

r.Data 
# "{\"data\":{\"Movie\":{\"releaseDate\":\"2010-08-28T20:00:00.000Z\",\"actors\":[{\"name\":\"Leonardo DiCaprio\"},{\"name\":\"Ellen Page\"},{\"name\":\"Tom Hardy\"},{\"name\":\"Joseph Gordon-Levitt\"},{\"name\":\"Marion Cotillard\"}]}}}"

Server

Here is one example for you to get started:

schema = Dict(
"query" => "Query"

,"Query"=> Dict(
    "persona"=>Dict("tipo"=>"Persona")
   ,"neomatrix"=>Dict("tipo"=>"Persona")
   )

,"Persona" => Dict(
    "edad"=>Dict("tipo"=>"Int")
   ,"nombre"=>Dict("tipo"=>"String")
  )

)


 resolvers=Dict(
    "Query"=>Dict(
        "neomatrix" => (root,args,ctx,info)->(return Dict("nombre"=>"josue","edad"=>26))
        ,"persona" => (root,args,ctx,info)->(return Dict("nombre"=>"Diana","edad"=>25))
    )
    ,"Persona"=>Dict(
      "edad" => (root,args,ctx,info)->(return root["edad"])
    )
)

my_schema = Schema(schema, resolvers)

Then Querying Diana.Schema is as simple as:

query= """
{
  neomatrix{
  	nombre
  }
}
"""
result = my_schema.execute(query)
# "{\"data\":{\"neomatrix\":{\"nombre\":\"josue\"}}}"

TODO

Documentation

Documentation and links to additional resources are available at https://neomatrixcode.gitbook.io/diana/