Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

License

NotificationsYou must be signed in to change notification settings

teamwalnut/rescript-urql

Repository files navigation

npmAll ContributorsBuild Status![Maintenance Status][maintenance-image]

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

📣 Please note these bindings were previously maintained by Formidable, but have since been taken over by the ReScript Brazil community.

✨Features

  • ⚛️ A fully featured GraphQL client forrescript-react.
  • ✅ Compile time type and schema validation.
  • ⚙️ Customizable behavior viaexchanges.
  • 🎣 Support foruseQuery,useMutation,useSubscription, anduseClient hooks!
  • ⚡ Support for server-side rendering with Next.js.

rescript-urql is a GraphQL client forrescript-react, allowing you to hook up your components to queries, mutations, and subscriptions. It provides bindings tourql 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 itspeerDependencies anddevDependencies.

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

We try to keep our bindings as close to latesturql as possible. However,urql tends to make releases a bit ahead ofrescript-urql. To get a compatible version, we recommend always staying strictly within this project'speerDependency range forurql.

ThegentypedevDependency is a requirement introduced byurql's use ofwonka.wonka's source uses@genType declarations, so when the BuckleScript / ReScript compiler attempts to compilewonka in your project, it'll need a local copy ofgentype to use.

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

If usingbs-platform>=8.0.0 you'll need to useyarn resolutions to specify a specific version ofwonka to resolve.urql has an explicit dependency on latestwonkav4, which is incompatible withbs-platform>=8.0.0. Seethis issue for more details.

In yourpackage.json, add the following:

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

If you're usingnpm, you may need to stay onbs-platform@7.3.2 untilurql takes a dependency onwonka>=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'sdevDependencies.

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

3. Updatebsconfig.json.

Add@urql/rescript,wonka, and@reasonml-community/graphql-ppx to yourbs-dependencies and@reasonml-community/graphql-ppx/ppx to yourppx_flags inbsconfig.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 likegraphql-cli. You should generate a file calledgraphql_schema.json at the root of your project thatgraphql-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, headhere.

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

Simply re-run this script at anytime to regenerate thegraphql_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 athttp://localhost:3000. Edit the example freely to watch changes take effect.

Editingrescript-urql source files

If developing on the mainrescript-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-queryyarn cleanyarn

Since we arelinking the examples' dependency onrescript-urql to thesrc directory, it's important to clean builds between changes to prevent any stale or erroneous artifacts.

Getting Involved

Please help out byopening an issue orfiling a PR.

Contributors

This project follows theall 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

💻

About

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

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors23

Languages


[8]ページ先頭

©2009-2025 Movatter.jp