All Projects → dmjio → graphql-meta

dmjio / graphql-meta

Licence: other
Lexing, parsing, pretty-printing, and metaprogramming facilities for dealing with GraphQL schemas and queries

Programming Languages

haskell
3896 projects
Yacc
648 projects
RPC
45 projects
Nix
1067 projects

Projects that are alternatives of or similar to graphql-meta

facebook-tool-seller
Facebook Tool Seller Version 1.0.1
Stars: ✭ 25 (+56.25%)
Mutual labels:  facebook
Ananas
An easy image editor integration for your Android apps.
Stars: ✭ 186 (+1062.5%)
Mutual labels:  facebook
googleAnalyticsProphetR
Applying Facebook's prophet on Google Analytics data
Stars: ✭ 30 (+87.5%)
Mutual labels:  facebook
instagram-stories
Get the Instagram Stories in Node.js and Browser
Stars: ✭ 86 (+437.5%)
Mutual labels:  facebook
oauth
Allow users to log in with GitHub, Twitter, Facebook, and more!
Stars: ✭ 21 (+31.25%)
Mutual labels:  facebook
Data-mining-python-script
It contain various script on web crawling/ data mining of social web(RSS,facebook,twitter,Linkedin)
Stars: ✭ 24 (+50%)
Mutual labels:  facebook
py010parser
A modified pycparser to parse 010 templates
Stars: ✭ 49 (+206.25%)
Mutual labels:  lexer
no-facebook-emoji
Get rid of those ugly emojis now! [stopped working 😢]
Stars: ✭ 15 (-6.25%)
Mutual labels:  facebook
facebook-py-sdk
Facebook Python SDK
Stars: ✭ 15 (-6.25%)
Mutual labels:  facebook
universal-routed-flux-demo
The code in this repo is intended for people who want to get started building universal flux applications, with modern and exciting technologies such as Reactjs, React Router and es6.
Stars: ✭ 31 (+93.75%)
Mutual labels:  facebook
Firebook
A facebook like app using Firebase
Stars: ✭ 31 (+93.75%)
Mutual labels:  facebook
ueberauth facebook
Facebook OAuth2 Strategy for Überauth.
Stars: ✭ 72 (+350%)
Mutual labels:  facebook
koleton
The easiest library to show skeleton screens in an Android app.
Stars: ✭ 84 (+425%)
Mutual labels:  facebook
video-downloader
Video Downloader for Facebook.
Stars: ✭ 63 (+293.75%)
Mutual labels:  facebook
b11
11 DIGIT FACEBOOK ACCOUNTS PASSWORD CRACKER <br> FOR BANGLADESHI TERMUX USERS
Stars: ✭ 87 (+443.75%)
Mutual labels:  facebook
node-facebook-twitter-google-github-login
Node, Express, Mongoose, Passport, Facebook, Twitter, Google and Github Authentication (Login)
Stars: ✭ 31 (+93.75%)
Mutual labels:  facebook
aboutmeinfo-telegram-bot
ℹ️ About Me Info Bot: Share your social media and links on Telegram
Stars: ✭ 20 (+25%)
Mutual labels:  facebook
pascal-interpreter
A simple interpreter for a large subset of Pascal language written for educational purposes
Stars: ✭ 21 (+31.25%)
Mutual labels:  lexer
KASocialLogins
This is Social login library in which you can login through Facebook , LinkedIn and Google
Stars: ✭ 15 (-6.25%)
Mutual labels:  facebook
fb-sdk-cljs
facebook javascript sdk wrapper for clojurescript
Stars: ✭ 13 (-18.75%)
Mutual labels:  facebook

graphql-meta

A GraphQL toolkit providing the following:

  • Alex Lexer of the GraphQL lexical specification.
  • Happy Parser of the GraphQL BNF Grammar.
  • Pretty printer of the GraphQL abstract syntax tree (AST) for human consumption.
  • QuickCheck generators for creating random AST fragments
    • Used in conjunction with pretty printing to establish round trip property tests.
    • Source
  • Generics implementation providing correct-by-construction Schema at compile time.
  • QuasiQuoter providing inline definitions of ExecutableDefinitions.

Table of Contents

Query

{-# LANGUAGE QuasiQuotes #-}

module Main (main) where

import GraphQL.QQ (query)

main :: IO ()
main = print [query| { building (id: 123) {floorCount, id}} |]

Result

QueryDocument {getDefinitions = [
  DefinitionOperation (AnonymousQuery [
	SelectionField (Field Nothing (Name {unName = "building"}) [
	  Argument (Name {unName = "id"}) (ValueInt 123)] [] [
	SelectionField (Field Nothing (Name {unName = "floorCount"}) [] [] [])
	  , SelectionField (Field Nothing (Name {unName = "id"}) [] [] [])
	  ])
	])
  ]}

Substitution

GraphQL ExecutableDefinition abstract syntax tree rewriting is made possible via Template Haskell's metavariable substitution. During QuasiQuotation all unbound variables in a GraphQL query that have identical names inside the current scope will automatically be translated into GraphQL AST terms and substituted.

buildingQuery
  :: Int
  -> ExecutableDefinition
buildingQuery buildingId =
  [query| { building (id: $buildingId) {floorCount, id}} |]

Result

QueryDocument {getDefinitions = [
  DefinitionOperation (AnonymousQuery [
	SelectionField (Field Nothing (Name {unName = "building"}) [
	  Argument (Name {unName = "buildingId"}) (ValueInt 4)] [] [
	SelectionField (Field Nothing (Name {unName = "floorCount"}) [] [] [])
	  , SelectionField (Field Nothing (Name {unName = "id"}) [] [] [])
	  ])
	])
  ]}

Generics

It is possible to derive GraphQL schema using GHC.Generics. Simply import GHC.Generics, derive Generic (must enable the DeriveGeneric language extension) and make an instance of ToObjectTypeDefintion. See below for an example:

{-# LANGUAGE DeriveGeneric #-}

module Main where

import           GHC.Generics                    (Generic)
import           GraphQL.Internal.Syntax.Encoder (schemaDocument)
import           Data.Proxy                      (Proxy)
import qualified Data.Text.IO                    as T
import           GraphQL.Generic                 (ToObjectTypeDefinition(..))

data Person = Person
  { name :: String
  , age  :: Int
  } deriving (Show, Eq, Generic)

instance ToObjectTypeDefinition Person

showPersonSchema :: IO ()
showPersonSchema = print $ toObjectTypeDefinition (Proxy @ Person)

-- type Person{name:String!,age:Int!}

Limitations

  • Generic deriving is currently only supported on product types with record field selectors.
  • Only ObjectTypeDefintion is currently supported.

Roadmap

  • Generic deriving of ScalarTypeDefintion and EnumTypeDefintion.

Maintainers

Credit

License

BSD3 2018-2019 Urbint Inc.

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].