{"id":20486872,"url":"https://github.com/rricard/bs-graphql-bindings","last_synced_at":"2025-04-13T15:23:54.713Z","repository":{"id":73184290,"uuid":"100818888","full_name":"rricard/bs-graphql-bindings","owner":"rricard","description":"BuckleScript binding for graphql-js","archived":false,"fork":false,"pushed_at":"2017-12-18T02:04:59.000Z","size":66,"stargazers_count":50,"open_issues_count":2,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-06T21:46:45.422Z","etag":null,"topics":["apollo","bucklescript","graphql","ocaml","reasonml"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rricard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-19T20:12:49.000Z","updated_at":"2023-06-20T17:00:29.000Z","dependencies_parsed_at":"2023-06-25T20:37:24.730Z","dependency_job_id":null,"html_url":"https://github.com/rricard/bs-graphql-bindings","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fbs-graphql-bindings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fbs-graphql-bindings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fbs-graphql-bindings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rricard%2Fbs-graphql-bindings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rricard","download_url":"https://codeload.github.com/rricard/bs-graphql-bindings/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248733485,"owners_count":21153025,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apollo","bucklescript","graphql","ocaml","reasonml"],"created_at":"2024-11-15T16:38:56.877Z","updated_at":"2025-04-13T15:23:54.707Z","avatar_url":"https://github.com/rricard.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BuckleScript GraphQL bindings\n\n[![CircleCI](https://circleci.com/gh/rricard/bs-graphql-bindings.svg?style=svg)](https://circleci.com/gh/rricard/bs-graphql-bindings)\n\nThis repository stores a collection of [BuckleScript](https://bucklescript.github.io/) bindings for various, widely used, [GraphQL](http://graphql.org/) projects.\n\n## Packages\n\nThe following packages are contained in this repository and published on npm:\n\n| Package | Binds to | NPM | Description |\n|---------|----------|-----|-------------|\n| [`bs-graphql`](./packages/bs-graphql) | [`graphql-js`](https://github.com/graphql/graphql-js/) | [![npm version](https://badge.fury.io/js/bs-graphql.svg)](https://badge.fury.io/js/bs-graphql) | Core GraphQL bindings over the JS reference implementation |\n| [`bs-graphql-tools`](./packages/bs-graphql-tools) | [`graphql-tools`](https://github.com/apollographql/graphql-tools/) | [![npm version](https://badge.fury.io/js/bs-graphql-tools.svg)](https://badge.fury.io/js/bs-graphql-tools) | Bindings for the Apollo GraphQL server tools |\n| [`bs-apollo-server-express`](./packages/bs-apollo-server-express) | [`apollo-server-express`](https://github.com/apollographql/apollo-server/) | [![npm version](https://badge.fury.io/js/bs-apollo-server-express.svg)](https://badge.fury.io/js/bs-apollo-server-express) | Bindings to mount an apollo server on express |\n\n\u003e **WARNING**: Most of those bindings are **partial** for now! Please consult each binding's readme for more information.\n\n## Guides\n\n### Your first Reason-GraphQL server\n\n**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.\n\nThis short guide will show you how to setup a GraphQL server fast.\n\nFirst, you will need a reason codebase:\n\n```sh\nnpm install -g bs-platform\nbsb -init my-graphql-server -theme basic-reason\ncd my-graphql-server\nyarn install || npm install\n```\n\nNow, you need to install the packages here and graphql as well as express:\n\n```\nyarn add graphql express body-parser \\\n  bs-express bs-graphql bs-apollo-server-express bs-graphql-tools || \\\nnpm install --save graphql express body-parser \\\n  bs-express bs-graphql bs-apollo-server-express bs-graphql-tools\n```\nAdd the bindings in `bsconfig.json`:\n\n```json\n{\n  \"name\": \"my-graphql-server\",\n  \"sources\": [\n    \"src\"\n  ],\n  \"bs-dependencies\" : [\n    \"bs-express\",\n    \"bs-graphql\",\n    \"bs-graphql-tools\",\n    \"bs-apollo-server-express\"\n  ]\n}\n```\n\nWe're starting the development, you should run a watch process: `yarn watch || npm run watch`.\n\nRemove `demo.re` and add the following files:\n\nFirst we'll define a Reason type alongside an associated GraphQL schema and resolver functions: `Episode.re`:\n\n```reason\ntype t = {\n  name: string,\n  number: int\n};\nlet hope = {name: \"A New Hope\", number: 4};\nlet empire = {name: \"The Empire Strikes Back\", number: 5};\nlet jedi = {name: \"The Return of the Jedi\", number: 6};\nlet getName e =\u003e e.name;\nlet getNumber e =\u003e e.number;\nlet typeDef = \"type Episode { name: String!, number: Int! }\";\nlet resolvers = {\"name\": getName, \"number\": getNumber};\n```\n\nThen, we'll define the base Query type similarly: `Query.re`:\n\n```reason\nlet getEpisodes () =\u003e [|Episode.hope, Episode.empire, Episode.jedi|];\nlet getFavoriteEpisode () =\u003e Episode.empire;\nlet typeDef = \"type Query { episodes: [Episode!]!, favoriteEpisode: Episode! }\";\nlet resolvers = {\"episodes\": getEpisodes, \"favoriteEpisode\": getFavoriteEpisode};\n```\n\nWe can now put together a schema: `Schema.re`:\n\n```reason\nlet typeDefs = Query.typeDef ^ \" \" ^ Episode.typeDef;\nlet resolvers = {\"Query\": Query.resolvers, \"Episode\": Episode.resolvers};\nlet schema = GraphQLTools.makeExecutableSchema {\"typeDefs\": typeDefs, \"resolvers\": resolvers};\n```\n\nAnd finally, we can mount a server: `Server.js`:\n\n```reason\nlet port = 8080;\n\nexternal bodyParserJson : unit =\u003e Express.Middleware.t = \"json\" [@@bs.module \"body-parser\"];\n\nlet () = {\n  let app = Express.App.make ();\n  Express.App.use app (bodyParserJson ());\n  let graphqlMiddleware = ApolloServerExpress.createGraphQLExpressMiddleware Schema.schema;\n  let graphiqlMiddleware = ApolloServerExpress.createGraphiQLExpressMiddleware \"/graphql\";\n  Express.App.useOnPath app graphqlMiddleware path::\"/graphql\";\n  Express.App.useOnPath app graphiqlMiddleware path::\"/graphiql\";\n  Express.App.listen app ::port;\n  Js.log (\"GraphQL Server listening on http://localhost:\" ^ string_of_int port)\n};\n```\n\nIf your watcher worked so far, you can now run the server and run a query against it:\n\n```sh\nnode ./lib/js/src/server.js\ncurl --request POST \\\n  --url http://localhost:8080/graphql \\\n  --header 'content-type: application/json' \\\n  --data '{\"query\":\"{ favoriteEpisode { name, number }}\"}'\n```\n\n## Contributing\n\nPlease read the [CONTRIBUTING](./CONTRIBUTING.md) document if you want to help or report issues.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frricard%2Fbs-graphql-bindings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frricard%2Fbs-graphql-bindings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frricard%2Fbs-graphql-bindings/lists"}