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
{{ message }}
This repository was archived by the owner on Mar 25, 2021. It is now read-only.
feat: Add useTopics model hook and query for topics listing
- This commit adds a new `useTopics` model hook, which makes GraphQL
requests to the server to administer Kafka topics.
- The hook returns a set of sub-hooks, with just the `useGetTopics`
sub-hook implemented for now. `useGetTopics` returns the list of topics
(including name, number of partitions and number of replicas).
Contributes to: #124
Signed-off-by: Andrew Borley <[email protected]>
This directory contains custom [React Hooks](https://reactjs.org/docs/hooks-intro.html#motivation). Unlike the [Hooks](../Hooks/README.md), these hooks encapsulate specific business logic for views to utilise.
4
+
5
+
## Test approach
6
+
7
+
Elements should be tested in a functional manor. See [Test Driven Development](../../docs/Test.md#style-of-test).
8
+
9
+
## Expected files
10
+
11
+
For a given model `useFoo`, the expected files are as follows:
12
+
13
+
```
14
+
Models/
15
+
index.ts
16
+
types.ts
17
+
useFoo/
18
+
README.md
19
+
useFoo.ts
20
+
useFoo.spec.ts
21
+
useFoo.assets.ts
22
+
useFoo.types.ts
23
+
```
24
+
25
+
Where:
26
+
27
+
- index.ts acts as a barrel file, exporting the hooks defined in the Hooks directory
28
+
- types.ts acts as a barrel file, exporting all the public types of each context
29
+
- README.md is the readme for this hook, detailing design choices and usage
30
+
- useFoo.ts is the hook implementation
31
+
- useFoo.spec.ts are the tests for this hook
32
+
- useFoo.assets.ts are the test assets for this hook
33
+
- useFoo.types.ts are the types for this hook
34
+
35
+
## Implemented hooks
36
+
37
+
-[`useTopics`](./useTopics/README.md) - a hook providing sub-hooks to administer Kafka topics via GraphQL queries.
The `useTopics` hook returns sub-hooks to administer Kafka topics via GraphQL queries to the server `/api` endpoint. The sub-hooks returned by the `useTopics` hook are:
4
+
5
+
-`useGetTopics()` - returns the list of topics, including name, partitions count and replicas count, as an [Apollo `QueryResult` object](https://www.apollographql.com/docs/react/api/react/hooks/#result).
0 commit comments