GithubHelp home page GithubHelp logo

tarsbase / purescript-graphql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hendrikniemann/purescript-graphql

0.0 0.0 0.0 108 KB

Typesafe wrapper around GraphQL.js

Home Page: https://hendrikniemann.github.io/purescript-graphql

License: MIT License

JavaScript 22.73% PureScript 77.27%

purescript-graphql's Introduction

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"
    }

purescript-graphql's People

Contributors

hendrikniemann avatar rndnoise avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.