All Projects → rricard → bs-graphql-bindings

rricard / bs-graphql-bindings

Licence: MIT License
BuckleScript binding for graphql-js

Programming Languages

ocaml
1615 projects
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to bs-graphql-bindings

Learn Graphql
Real world GraphQL tutorials for frontend developers with deadlines!
Stars: ✭ 586 (+1072%)
Mutual labels:  apollo, reasonml
Reason Apollo Hooks
Deprecated in favor of https://github.com/reasonml-community/graphql-ppx
Stars: ✭ 140 (+180%)
Mutual labels:  apollo, reasonml
bs-reason-apollo
ReactApollo bindings for BS
Stars: ✭ 23 (-54%)
Mutual labels:  apollo, reasonml
reasoncoin
No description or website provided.
Stars: ✭ 16 (-68%)
Mutual labels:  reasonml
stuyspec.com
🖼 The Stuyvesant Spectator's website, built with React, GraphQL, and Rails.
Stars: ✭ 22 (-56%)
Mutual labels:  apollo
apollo-chat-graphql-server
Apollo Chat is a Chat Service build on GraphQL Apollo with Subscriptions
Stars: ✭ 13 (-74%)
Mutual labels:  apollo
netlify-faunadb-graphql-auth
Netlify functions example with faunadb, graphql, and authorization
Stars: ✭ 57 (+14%)
Mutual labels:  apollo
timerlab
⏰ A simple and customizable timer
Stars: ✭ 94 (+88%)
Mutual labels:  reasonml
React-Realtime-Chat
A full-stack reproduction of the popular realtime chat application, Slack (http://slack.com) using React and GraphQL Subscriptions.
Stars: ✭ 16 (-68%)
Mutual labels:  apollo
reason-rt-binding-generator
Reason binding generator for react-toolbox
Stars: ✭ 18 (-64%)
Mutual labels:  reasonml
cadhub
We're out to raise awareness and put CodeCAD on the map. The success of CadHub can be measured by the amount it promotes the use of CodeCAD within the mechanical/manufacturing industry and the strength the CadHub community.
Stars: ✭ 204 (+308%)
Mutual labels:  apollo
apollo-rs
Spec compliant GraphQL Tools in Rust.
Stars: ✭ 314 (+528%)
Mutual labels:  apollo
graphql-reason-server-example
An example project to write a GraphQL server using Reason
Stars: ✭ 19 (-62%)
Mutual labels:  reasonml
apollo-docker
Apollo阿波罗配置中心docker
Stars: ✭ 23 (-54%)
Mutual labels:  apollo
bs-most
Reason/BuckleScript bindings for the Most.js reactive toolkit
Stars: ✭ 41 (-18%)
Mutual labels:  reasonml
graphql-fundamentals
A training repo for learning basic concepts in GraphQL on the client and server
Stars: ✭ 15 (-70%)
Mutual labels:  apollo
ruby-to-michelson
(Secure) Ruby to Liquidity w/ ReasonML Syntax / Michelson (Source-to-Source) Cross-Compiler Cheat Sheet / White Paper
Stars: ✭ 16 (-68%)
Mutual labels:  reasonml
advent-2017
Advent of Code 2017
Stars: ✭ 16 (-68%)
Mutual labels:  reasonml
udacity-alumni-fe
A front-end web application and bespoke publishing platform, built by Udacity Alumni for Udacity Alumni
Stars: ✭ 45 (-10%)
Mutual labels:  apollo
re-blossom
A Reason implementation of the blossom maximum-matching algorithm
Stars: ✭ 15 (-70%)
Mutual labels:  reasonml

BuckleScript GraphQL bindings

CircleCI

This repository stores a collection of BuckleScript bindings for various, widely used, GraphQL projects.

Packages

The following packages are contained in this repository and published on npm:

Package Binds to NPM Description
bs-graphql graphql-js npm version Core GraphQL bindings over the JS reference implementation
bs-graphql-tools graphql-tools npm version Bindings for the Apollo GraphQL server tools
bs-apollo-server-express apollo-server-express npm version Bindings to mount an apollo server on express

WARNING: Most of those bindings are partial for now! Please consult each binding's readme for more information.

Guides

Your first Reason-GraphQL server

TL;DR;: This repo has it all with a few interesting things more (such as snapshot testing with jest): https://github.com/rricard/graphql-reason-server-example.

This short guide will show you how to setup a GraphQL server fast.

First, you will need a reason codebase:

npm install -g bs-platform
bsb -init my-graphql-server -theme basic-reason
cd my-graphql-server
yarn install || npm install

Now, you need to install the packages here and graphql as well as express:

yarn add graphql express body-parser \
  bs-express bs-graphql bs-apollo-server-express bs-graphql-tools || \
npm install --save graphql express body-parser \
  bs-express bs-graphql bs-apollo-server-express bs-graphql-tools

Add the bindings in bsconfig.json:

{
  "name": "my-graphql-server",
  "sources": [
    "src"
  ],
  "bs-dependencies" : [
    "bs-express",
    "bs-graphql",
    "bs-graphql-tools",
    "bs-apollo-server-express"
  ]
}

We're starting the development, you should run a watch process: yarn watch || npm run watch.

Remove demo.re and add the following files:

First we'll define a Reason type alongside an associated GraphQL schema and resolver functions: Episode.re:

type t = {
  name: string,
  number: int
};
let hope = {name: "A New Hope", number: 4};
let empire = {name: "The Empire Strikes Back", number: 5};
let jedi = {name: "The Return of the Jedi", number: 6};
let getName e => e.name;
let getNumber e => e.number;
let typeDef = "type Episode { name: String!, number: Int! }";
let resolvers = {"name": getName, "number": getNumber};

Then, we'll define the base Query type similarly: Query.re:

let getEpisodes () => [|Episode.hope, Episode.empire, Episode.jedi|];
let getFavoriteEpisode () => Episode.empire;
let typeDef = "type Query { episodes: [Episode!]!, favoriteEpisode: Episode! }";
let resolvers = {"episodes": getEpisodes, "favoriteEpisode": getFavoriteEpisode};

We can now put together a schema: Schema.re:

let typeDefs = Query.typeDef ^ " " ^ Episode.typeDef;
let resolvers = {"Query": Query.resolvers, "Episode": Episode.resolvers};
let schema = GraphQLTools.makeExecutableSchema {"typeDefs": typeDefs, "resolvers": resolvers};

And finally, we can mount a server: Server.js:

let port = 8080;

external bodyParserJson : unit => Express.Middleware.t = "json" [@@bs.module "body-parser"];

let () = {
  let app = Express.App.make ();
  Express.App.use app (bodyParserJson ());
  let graphqlMiddleware = ApolloServerExpress.createGraphQLExpressMiddleware Schema.schema;
  let graphiqlMiddleware = ApolloServerExpress.createGraphiQLExpressMiddleware "/graphql";
  Express.App.useOnPath app graphqlMiddleware path::"/graphql";
  Express.App.useOnPath app graphiqlMiddleware path::"/graphiql";
  Express.App.listen app ::port;
  Js.log ("GraphQL Server listening on http://localhost:" ^ string_of_int port)
};

If your watcher worked so far, you can now run the server and run a query against it:

node ./lib/js/src/server.js
curl --request POST \
  --url http://localhost:8080/graphql \
  --header 'content-type: application/json' \
  --data '{"query":"{ favoriteEpisode { name, number }}"}'

Contributing

Please read the CONTRIBUTING document if you want to help or report issues.

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