Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A graphql parser and resolver for Elixir

NotificationsYou must be signed in to change notification settings

peburrows/plot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A GraphQL parser and resolver for Elixir.

This project is still a work in progress, but the eventual goal is to support the full GraphQL spec.

Basic Usage

Build a basic AST from a doc

"{  user {    id,    firstName,    lastName  }}"|>Plot.parse# returns:{:ok,[{:query,nil,[{:object,"user",nil,[],[{:field,"id",nil,[]},{:field,"firstName",nil,[]},{:field,"lastName",nil,[]}]}]}]}

Build Plot objects from a doc

"{  user {    id,    firstName,    lastName  }}"|>Plot.parse_and_generate# returns:%Plot.Document{fragments:[],operations:[%Plot.Query{name:nil,objects:[%Plot.Object{alias:nil,args:[],name:"user",fields:[%Plot.Field{alias:nil,args:[],name:"lastName"},%Plot.Field{alias:nil,args:[],name:"firstName"},%Plot.Field{alias:nil,args:[],name:"id"}]}]}],variables:[]}

Query resolution

Query resolution works via Elixir protocols. Implement theResolution protocol for the various nodes of your queries.

# ImplementationdefimplPlot.Resolution,for:Plot.Objectdodefresolve(%Plot.Object{name:"user"}=_obj,_context)do%{"firstName"=>"Phil","lastName"=>"Burrows",dontInclude:"this"}enddefresolve(%Plot.Object{name:"birthday"},_context)do%{"day"=>15,"month"=>12,"year"=>2015}endend# Resolutiondoc="{user {firstName, lastName, birthday {month, year}}}"|>Plot.parse_and_generatedoc.operations|>Enum.at(0)|>Plot.Resolver.resolve# returns:[%{"user"=>%{"birthday"=>%{"month"=>12,"year"=>2015},"firstName"=>"Phil","lastName"=>"Burrows"}}]

About

A graphql parser and resolver for Elixir

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors2

  •  
  •  

Languages


[8]ページ先頭

©2009-2025 Movatter.jp