Skip to content

Commit d9dc207

Browse files
committed
Update readme
1 parent 9bfbb91 commit d9dc207

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ npm install react-query-grpc-gateway
1919

2020
## Usage
2121

22+
- [useServiceQuery](#useservicequery)
23+
- [useServiceMutation](#useservicemutation)
24+
- [queryOptions](#queryoptions)
25+
26+
### useServiceQuery
27+
2228
`useServiceQuery` is a drop in replacement for `useQuery` that allows for the propagation of request configuration through the context.
2329

2430
Assuming you have a proto definition for a `UserService` with a `ReadUser`
@@ -91,6 +97,21 @@ The arguments for `useServiceQuery` are:
9197
`onError` can be used to customize error handling behavior at the request level,
9298
for example, don't even show React Query that a 401 occurred.
9399

100+
### useServiceMutation
101+
102+
`useServiceMutation` is a drop in replacement for `useMutation`.
103+
104+
```ts
105+
const mutation = useServiceMutation(UserService.UpdateUser, {});
106+
mutation.mutate({ id: userID, name: newName });
107+
```
108+
109+
### queryOptions
110+
111+
`queryOptions` can be used for consistency if you need to prefetch queries or
112+
use suspenses. It is only marginally more convenient than using the service
113+
method directly.
114+
94115
## Contributing
95116

96117
If you find issues or spot possible improvements, please submit a pull-request.

0 commit comments

Comments
 (0)