All Projects → FormidableLabs → rescript-urql

FormidableLabs / rescript-urql

Licence: MIT License
ReScript bindings for Formidable's Universal React Query Library, urql.

Programming Languages

ReScript
86 projects

Projects that are alternatives of or similar to rescript-urql

reasonreact-starter
Minimal yet powerful ReasonReact template
Stars: ✭ 33 (-85.65%)
Mutual labels:  reasonml, reasonreact
Reason Urql
Reason bindings for Formidable's Universal React Query Library, urql.
Stars: ✭ 203 (-11.74%)
Mutual labels:  graphql-client, reasonml
solar-weather
React Native Weather App w. Realm, Redux, ReasonReact & Forecast.io
Stars: ✭ 13 (-94.35%)
Mutual labels:  reasonml, reasonreact
re-blossom
A Reason implementation of the blossom maximum-matching algorithm
Stars: ✭ 15 (-93.48%)
Mutual labels:  reasonml
urql-devtools-exchange
The exchange for usage with Urql Devtools
Stars: ✭ 35 (-84.78%)
Mutual labels:  urql
ts-react-apollo
Thin-Layer around react apollo client to use typescript to the fullest
Stars: ✭ 18 (-92.17%)
Mutual labels:  graphql-client
bs-getenv
ReasonML/BuckleScript PPX for embedding env variables
Stars: ✭ 25 (-89.13%)
Mutual labels:  reasonml
map
🏳️‍🌈🗺 A map of community centers and other helpful information for queer (LGBTQ) people.
Stars: ✭ 15 (-93.48%)
Mutual labels:  graphql-client
awesome-ppx-reasonml
curated list of reasonml PPX rewriter
Stars: ✭ 28 (-87.83%)
Mutual labels:  reasonml
onetricks.net
(WIP) kayn-powered (typescript node.js) ReasonReact app presenting you a dashboard of high ELO one trick ponies in League of Legends
Stars: ✭ 13 (-94.35%)
Mutual labels:  reasonml
shmup.re
Learning Reason/OCaml by making an old-school canvas game.
Stars: ✭ 24 (-89.57%)
Mutual labels:  reasonml
ruby-to-michelson
(Secure) Ruby to Liquidity w/ ReasonML Syntax / Michelson (Source-to-Source) Cross-Compiler Cheat Sheet / White Paper
Stars: ✭ 16 (-93.04%)
Mutual labels:  reasonml
react-multiversal
React components that works everywhere (iOS, Android, Web, Node)
Stars: ✭ 43 (-81.3%)
Mutual labels:  reasonml
graphql-reason-server-example
An example project to write a GraphQL server using Reason
Stars: ✭ 19 (-91.74%)
Mutual labels:  reasonml
web-starter-kit
An opinionated starter kit with styled-system, graphql-hooks, mobx and nextjs (PWA)
Stars: ✭ 17 (-92.61%)
Mutual labels:  graphql-client
reason-rt-binding-generator
Reason binding generator for react-toolbox
Stars: ✭ 18 (-92.17%)
Mutual labels:  reasonml
reason-nodejs
Node bindings for Reason and Bucklescript
Stars: ✭ 105 (-54.35%)
Mutual labels:  reasonml
bs-graphql-bindings
BuckleScript binding for graphql-js
Stars: ✭ 50 (-78.26%)
Mutual labels:  reasonml
astro-design
Astro Design Components
Stars: ✭ 20 (-91.3%)
Mutual labels:  reasonml
relude-random
Composable random generators based on the PCG paper
Stars: ✭ 15 (-93.48%)
Mutual labels:  reasonml

rescript-urql

npm All Contributors Build Status ![Maintenance Status][maintenance-image]

ReScript bindings for Formidable's Universal React Query Library, urql.

Features

  • ⚛️ A fully featured GraphQL client for rescript-react.
  • Compile time type and schema validation.
  • ⚙️ Customizable behavior via exchanges.
  • 🎣 Support for useQuery, useMutation, useSubscription, and useClient hooks!
  • Support for server-side rendering with Next.js.

rescript-urql is a GraphQL client for rescript-react, allowing you to hook up your components to queries, mutations, and subscriptions. It provides bindings to urql that allow you to use the API in ReScript, with the benefits of a sound type system, blazing fast compilation, and opportunities for guided customization.

📋 Documentation

💾 Installation

1. Install @urql/rescript alongside its peerDependencies and devDependencies.

yarn add @urql/rescript urql graphql
yarn add gentype --dev

We try to keep our bindings as close to latest urql as possible. However, urql tends to make releases a bit ahead of rescript-urql. To get a compatible version, we recommend always staying strictly within this project's peerDependency range for urql.

The gentype devDependency is a requirement introduced by urql's use of wonka. wonka's source uses @genType declarations, so when the BuckleScript / ReScript compiler attempts to compile wonka in your project, it'll need a local copy of gentype to use.

1a. Important note for users of bs-platform>=8.0.0.

If using bs-platform>=8.0.0 you'll need to use yarn resolutions to specify a specific version of wonka to resolve. urql has an explicit dependency on latest wonka v4, which is incompatible with bs-platform>=8.0.0. See this issue for more details.

In your package.json, add the following:

"resolutions": {
  "wonka": "5.0.0-rc.1"
}

If you're using npm, you may need to stay on [email protected] until urql takes a dependency on wonka>=5.0.0.

2. Add @reasonml-community/graphql-ppx.

To get the most out of compile time type checks for your GraphQL queries, mutations, and subscriptions, we use @reasonml-community/graphql-ppx. Add this to your project's devDependencies.

yarn add @reasonml-community/graphql-ppx --dev

3. Update bsconfig.json.

Add @urql/rescript, wonka, and @reasonml-community/graphql-ppx to your bs-dependencies and @reasonml-community/graphql-ppx/ppx to your ppx_flags in bsconfig.json.

{
  "bs-dependencies": [
    "@urql/rescript",
    "wonka",
    "@reasonml-community/graphql-ppx"
  ],
  "ppx-flags": ["@reasonml-community/graphql-ppx/ppx"]
}

4. Send an introspection query to your API.

Finally, you'll need to send an introspection query to your GraphQl API, using a tool like graphql-cli. You should generate a file called graphql_schema.json at the root of your project that graphql-ppx can use to type check your queries. You should check this file into version control and keep it updated as your API changes.

For additional help, head here.

npx get-graphql-schema ENDPOINT_URL -j > graphql_schema.json

Simply re-run this script at anytime to regenerate the graphql_schema.json file according to your latest backend schema.

💻 Example Projects

rescript-urql has a nice set of examples showing how to use the hooks and client APIs to get the most out of GraphQL and ReScript in your app – check them out in the /examples folder. To run any of the examples, follow these steps.

# 1. Navigate into the example of choice.
cd examples/1-execute-query-mutation

# 2. Install dependencies.
yarn

# 3. In one terminal, compile the source in watch mode.
yarn start

# 4. In another terminal, start the demo app server.
yarn start:demo

The example will start up at http://localhost:3000. Edit the example freely to watch changes take effect.

Editing rescript-urql source files

If developing on the main rescript-urql source files (i.e. anything in /src/) and you want to test the changes in one of the examples, you'll need to do the following:

# Save your changes to source, then take the following steps.

# 1. Clean any artifacts from previous builds.
yarn clean

# 2. Rebuild the source.
yarn build

# 3. Clean example build and reinstall dependencies.
cd examples/2-query
yarn clean
yarn

Since we are linking the examples' dependency on rescript-urql to the src directory, it's important to clean builds between changes to prevent any stale or erroneous artifacts.

Getting Involved

Please help out by opening an issue or filing a PR.

Contributors

This project follows the all contributors spec. Thanks to these wonderful folks for contributing (Emoji Key):


Parker Ziegler

💻 📖 👀 🤔

Khoa Nguyen

💻 📖

Phil Plückthun

🤔

Kara Stubbs

💻 ⚠️ 💡

Marcos Felipe Pimenta Rodrigues

📖

Gustavo Aguiar

💻 💡

Avery Morin

🤔 💻 💡 📖

Alain Armand

💻 💡

Robin Weser

📖

Cem Turan

📖

Huy Nguyen

📖

Sean Grove

💻 💡 🤔 📖

Tomasz Cichocinski

💻 🐛

Jovi De Croock

💻

Corentin Leruth

📖 💻

Joel Jeddeloh

💻

hui.liu

📖

Kévin Combriat

💻 🐛 🤔

Amirali Esmaeili

💻 💡

Alexander Varwijk

💻

Maintenance Status

Archived: This project is no longer maintained by Formidable. We are no longer responding to issues or pull requests unless they relate to security concerns. We encourage interested developers to fork this project and make it their own!

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