• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

neomatrixcode/Diana.jl: GraphQL for Julia

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

neomatrixcode/Diana.jl

开源软件地址(OpenSource Url):

https://github.com/neomatrixcode/Diana.jl

开源编程语言(OpenSource Language):

Julia 100.0%

开源软件介绍(OpenSource Introduction):

Diana.jl

A Julia GraphQL client/server implementation.

DOI

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.

  • Easy to use: Diana.jl helps you use GraphQL in Julia without effort.
  • Data agnostic: Diana.jl supports any type of data source: SQL, NoSQL, etc. The intent is to provide a complete API and make your data available through GraphQL.
  • Make queries: Diana.jl allows queries to graphql schemas.

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

  • Client
  • Lexer
  • Parser
  • Query validation
  • Schemas / Types
  • Query execution
    • Arguments
    • Scalar types
    • Multiple forms of resolution
    • Extract variable values
    • Complex types (List, Object, etc)
    • Fragments in queries
    • Directives
  • Mutation execution
  • Subscriptions execution
  • Introspection
  • Depth of the query
  • Middleware

Documentation

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




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
serverless-components/graphql: ⚡ Deploy and manage GraphQL applications on serv ...发布时间:2022-06-13
下一篇:
adobe/aem-guides-wknd-graphql发布时间:2022-06-13
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap