Typesafe wrapper around GraphQL.js
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Add docs section about input types Dec 20, 2018
src Introduce recursive record types Dec 7, 2018
.gitignore Create some WIP documentation Nov 5, 2018
LICENSE Add license Sep 10, 2018
README.md Add minimal example to README Nov 27, 2018
bower.json v1.0.1 Dec 1, 2018
package-lock.json Make list type work for input and output Nov 19, 2018
package.json Make list type work for input and output Nov 19, 2018

README.md

Purescript GraphQL

PureScript GraphQL is a wrapper around GraphQL.js. It contains powerful, typed bindings that will make building GraphQL servers as typesafe as possible. Furthermore it automatically translates Affs into promises and Maybes into null values where they would be expected by the underlying JavaScript implementation.

Latest release License

Installation

bower install purescript-graphql
npm install graphql-js

Module documentation is published on Pursuit.

Getting started

This is the minimal code that is needed to execute a GraphQL query. If you want to get started with an HTTP server check out the example repository or follow along the tutorial.

module Main where

import Prelude

import Data.Argonaut.Core (stringify)
import Data.Either (either)
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Effect.Aff (runAff_)
import Effect.Console as Console
import GraphQL (graphql)
import GraphQL.Type as GraphQL

main :: Effect Unit
main = runAff_ (either (show >>> Console.error) (stringify >>> Console.log)) $
  graphql schema "{ hello }" unit unit Nothing Nothing

schema :: GraphQL.Schema Unit Unit
schema = GraphQL.schema queryType Nothing

queryType :: GraphQL.ObjectType Unit (Maybe Unit)
queryType =
  GraphQL.objectType
    "Query"
    (Just "The main query type")
    { hello:
        GraphQL.field'
          (GraphQL.nonNull GraphQL.string)
          (Just "A simple field that always returns \"world\".")
          \_ _ -> pure "world"
    }