You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [3.0.0-rc.0] - 2020-11-12
9
+
10
+
This release is the first release candidate for v3.0.0, which will use `@reasonml-community/graphql-ppx` as our PPX preprocessor for GraphQL operations. Breaking changes will be listed in the release notes for the first stable release of v3.0.0.
This release brings our `urql` dependency up to v1.10.0, at parity with the current state of `urql` 🙌. There are no code changes involved from the previous RC release.
####1. Install `reason-urql` and its `peerDependencies`.
31
+
### 1. Install `reason-urql` and its `peerDependencies`.
32
32
33
33
```sh
34
34
yarn add reason-urql urql graphql
35
35
```
36
36
37
37
We try to keep our bindings as close to latest `urql` as possible. However, `urql` tends to make releases a bit ahead of `reason-urql`. To get a compatible version, we recommend always staying strictly within this project's `peerDependency` range for `urql`.
38
38
39
-
#### 2. Add `@reasonml-community/graphql-ppx`.
39
+
#### 1a. **Important note for users of `bs-platform>=8.0.0`**.
40
+
41
+
If using `bs-platform>=8.0.0` you'll need to use [`yarn resolutions`](https://classic.yarnpkg.com/en/docs/selective-version-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](https://github.com/kitten/wonka/issues/85) for more details.
42
+
43
+
In your `package.json`, add the following:
44
+
45
+
```json
46
+
"resolutions": {
47
+
"wonka": "5.0.0-rc.1"
48
+
}
49
+
```
50
+
51
+
If you're using `npm`, you may need to stay on `[email protected]` until `urql` takes a dependency on `wonka>=5.0.0`.
52
+
53
+
### 2. Add `@reasonml-community/graphql-ppx`.
40
54
41
55
To get the most out of compile time type checks for your GraphQL queries, mutations, and subscriptions, we use [`@reasonml-community/graphql-ppx`](https://github.com/reasonml-community/graphql-ppx). Add this to your project's `devDependencies`.
42
56
43
57
```sh
44
58
yarn add @reasonml-community/graphql-ppx --dev
45
59
```
46
60
47
-
####3. Update `bsconfig.json`.
61
+
### 3. Update `bsconfig.json`.
48
62
49
63
Add `reason-urql`, `wonka`, and `@reasonml-community/graphql-ppx` to your `bs-dependencies` and `@reasonml-community/graphql-ppx/ppx` to your `ppx_flags` in `bsconfig.json`.
50
64
@@ -59,7 +73,7 @@ Add `reason-urql`, `wonka`, and `@reasonml-community/graphql-ppx` to your `bs-de
59
73
}
60
74
```
61
75
62
-
####4. Send an introspection query to your API.
76
+
### 4. Send an introspection query to your API.
63
77
64
78
Finally, you'll need to send an introspection query to your GraphQl API, using a tool like [`graphql-cli`](https://github.com/Urigo/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.
Copy file name to clipboardExpand all lines: docs/error.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ switch (response) {
27
27
Depending on the types of errors you get from your GraphQL API, you may want to do different things. Here's an example showing how to handle `networkError`s and `graphQLErrors` indepedently.
28
28
29
29
```reason
30
-
let ({ response }, _) = useQuery(~request, ());
30
+
let ({ response }, _) = useQuery(~query=(module MyQuery), ());
Copy file name to clipboardExpand all lines: docs/getting-started.md
+19-25Lines changed: 19 additions & 25 deletions
Original file line number
Diff line number
Diff line change
@@ -4,19 +4,19 @@ This document well help you get started with `reason-urql`. It picks up right wh
4
4
5
5
## Setting Up the Client
6
6
7
-
To get started with `reason-urql`, the first thing you'll want to do is create your client. Your client is the core orchestrator of communication with your GraphQL API, handling all outgoing requests and incoming responses. To create a client, simply call the `make` function from the `Client` module.
7
+
To get started with `reason-urql`, the first thing you'll want to do is create your client. Your client is the core orchestrator of communication with your GraphQL API, handling all outgoing requests and incoming responses. To create a client, call the `make` function from the `Client` module.
8
8
9
9
```reason
10
10
open ReasonUrql;
11
11
12
12
let client = Client.make(~url="https://mygraphqlapi.com/graphql", ());
13
13
```
14
14
15
-
The `client` accepts a few other configuration options, including `fetchOptions` and `exchanges`, but only `url` is required. By default, `reason-urql` will apply `urql`'s `defaultExchanges` if no exchanges are provided; this will include the `fetchExchange` for executing requests, the `cacheExchange` for caching responses from your API, and the `dedupExchange` for deduplicating in-flight requests. It will also apply standard fetch options if no `fetchOptions` argument is provided, using `POST` as the request method and `application/json` as the `Content-Type` header. We'll see later how to work with these options.
15
+
The `client` accepts a few other configuration options, including `fetchOptions` and `exchanges`, but only `url` is required. By default, `reason-urql` will apply `urql`'s `defaultExchanges` if no exchanges are provided; this will include the `fetchExchange` for executing requests, the `cacheExchange` for caching responses from your API, and the `dedupExchange` for deduplicating in-flight requests. It will also apply standard fetch options if no `fetchOptions` argument is provided, using `POST` as the HTTP method and `application/json` as the `Content-Type` header. We'll see later how to work with these options.
16
16
17
17
## Linking Client with Provider
18
18
19
-
Once you have your `Client` setup, you'll need to pass it to your `Provider`, which should wrap the root level of your application. This allows `reason-urql`'s hooks to access the `Client` to execute operations lower down in your React tree.
19
+
Once you have your `Client` setup, you'll need to pass it to your `Provider`, which should wrap the root level of your application. This allows `reason-urql`'s hooks to access the `Client`in order to execute operations lower down in your React tree.
20
20
21
21
```reason
22
22
open ReasonUrql;
@@ -52,11 +52,9 @@ module DogsQuery = [%graphql
52
52
53
53
[@react.component]
54
54
let make = () => {
55
-
/* Build your request by calling .make on your query. */
56
-
let request = DogsQuery.make();
57
-
58
-
/* Pass the request to useQuery. */
59
-
let (Hooks.{ response }, executeQuery) = Hooks.useQuery(~request, ());
55
+
/* Pass the graphql-ppx module as a first-class module to useQuery. */
56
+
let (Hooks.{response}, executeQuery)
57
+
= Hooks.useQuery(~query=(module DogsQuery), ());
60
58
61
59
/* Pattern match on the response variant.
62
60
This variant has constructors for Fetching, Data(d), PartialData(d, e) Error(e), and Empty. */
Sweet 😎! We've executed a query with our `useQuery` hook. Notice that we didn't have to write _any_ types to get 💯% type inference and type safety on the response. We use type information included in the query module you pass to `useQuery` to ensure that you're using the data returned by your query in a fully safe way.
83
+
Sweet 😎! We've executed a query with our `useQuery` hook. Notice that we didn't have to write _any_ types to get 💯% type inference and type safety on the response. We use type information included in the query module you pass to `useQuery` to ensure that you're using the data returned by your query in a fully type-safe way.
86
84
87
85
## Can I See an Example?
88
86
89
-
Check out the example in `examples/2-query` to see a more involved example of using `useQuery`, in addition to `reason-urql`'s `Query` component.
87
+
Check out the example in `examples/2-query` to see a more involved example of using `useQuery`.
"Execute the Mutation (and Reward a Good Dog)"->React.string
145
139
</button>,
146
140
[|executeMutation|]
@@ -165,4 +159,4 @@ let make = (~key: string) => {
165
159
166
160
## Can I See an Example?
167
161
168
-
Check out the example in `examples/3-mutation` to see a more involved example of using `useMutation`, in addition to `reason-urql`'s `Mutation` component.
162
+
Check out the example in `examples/3-mutation` to see a more involved example of using `useMutation`.
0 commit comments