Skip to content

Commit 186688a

Browse files
committed
docs: Add schema table to README
1 parent a725050 commit 186688a

File tree

7 files changed

+466
-54
lines changed

7 files changed

+466
-54
lines changed

.changeset/early-balloons-judge.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@data-client/normalizr': patch
3+
'@data-client/endpoint': patch
4+
'@data-client/rest': patch
5+
'@data-client/graphql': patch
6+
---
7+
8+
Add schema table to README

README.md

Lines changed: 75 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -298,12 +298,78 @@ For the small price of 9kb gziped.    [🏁Get started now](https://da
298298
- [Endpoints](https://dataclient.io/rest/api/Endpoint): [RestEndpoint](https://dataclient.io/rest/api/RestEndpoint), [GQLEndpoint](https://dataclient.io/graphql/api/GQLEndpoint)
299299
- [Resources](https://dataclient.io/docs/getting-started/resource): [resource()](https://dataclient.io/rest/api/resource), [hookifyResource()](https://dataclient.io/rest/api/hookifyResource)
300300
- [Data model](https://dataclient.io/docs/concepts/normalization)
301-
- [Entity](https://dataclient.io/rest/api/Entity), [schema.Entity](https://dataclient.io/rest/api/schema.Entity) mixin, [GQLEntity](https://dataclient.io/graphql/api/GQLEntity)
302-
- [Object](https://dataclient.io/rest/api/Object)
303-
- [Array](https://dataclient.io/rest/api/Array)
304-
- [Values](https://dataclient.io/rest/api/Values)
305-
- [All](https://dataclient.io/rest/api/All)
306-
- [Collection](https://dataclient.io/rest/api/Collection)
307-
- [Query](https://dataclient.io/rest/api/Query)
308-
- [Union](https://dataclient.io/rest/api/Union)
309-
- [Invalidate](https://dataclient.io/rest/api/Invalidate)
301+
<table>
302+
<thead>
303+
<tr>
304+
<th>Data Type</th>
305+
<th>Mutable</th>
306+
<th>Schema</th>
307+
<th>Description</th>
308+
<th><a href="https://dataclient.io/rest/api/schema#queryable">Queryable</a></th>
309+
</tr>
310+
</thead>
311+
<tbody><tr>
312+
<td rowSpan="4"><a href="https://en.wikipedia.org/wiki/Object_(computer_science)">Object</a></td>
313+
<td align="center">✅</td>
314+
<td><a href="https://dataclient.io/rest/api/Entity">Entity</a>, <a href="https://dataclient.io/rest/api/schema.Entity">schema.Entity</a> mixin</td>
315+
<td>single <em>unique</em> object</td>
316+
<td align="center">✅</td>
317+
</tr>
318+
<tr>
319+
<td align="center">✅</td>
320+
<td><a href="https://dataclient.io/rest/api/Union">Union(Entity)</a></td>
321+
<td>polymorphic objects (<code>A | B</code>)</td>
322+
<td align="center">✅</td>
323+
</tr>
324+
<tr>
325+
<td align="center">🛑</td>
326+
<td><a href="https://dataclient.io/rest/api/Object">Object</a></td>
327+
<td>statically known keys</td>
328+
<td align="center">🛑</td>
329+
</tr>
330+
<tr>
331+
<td align="center"></td>
332+
<td><a href="https://dataclient.io/rest/api/Invalidate">Invalidate(Entity)</a></td>
333+
<td><a href="https://dataclient.io/docs/concepts/expiry-policy#invalidate-entity">delete an entity</a></td>
334+
<td align="center">🛑</td>
335+
</tr>
336+
<tr>
337+
<td rowSpan="3"><a href="https://en.wikipedia.org/wiki/List_(abstract_data_type)">List</a></td>
338+
<td align="center">✅</td>
339+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Array)</a></td>
340+
<td>growable lists</td>
341+
<td align="center">✅</td>
342+
</tr>
343+
<tr>
344+
<td align="center">🛑</td>
345+
<td><a href="https://dataclient.io/rest/api/Array">Array</a></td>
346+
<td>immutable lists</td>
347+
<td align="center">🛑</td>
348+
</tr>
349+
<tr>
350+
<td align="center">✅</td>
351+
<td><a href="https://dataclient.io/rest/api/All">All</a></td>
352+
<td>list of all entities of a kind</td>
353+
<td align="center">✅</td>
354+
</tr>
355+
<tr>
356+
<td rowSpan="2"><a href="https://en.wikipedia.org/wiki/Associative_array">Map</a></td>
357+
<td align="center">✅</td>
358+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Values)</a></td>
359+
<td>growable maps</td>
360+
<td align="center">✅</td>
361+
</tr>
362+
<tr>
363+
<td align="center">🛑</td>
364+
<td><a href="https://dataclient.io/rest/api/Values">Values</a></td>
365+
<td>immutable maps</td>
366+
<td align="center">🛑</td>
367+
</tr>
368+
<tr>
369+
<td>any</td>
370+
<td align="center"></td>
371+
<td><a href="https://dataclient.io/rest/api/Query">Query(Queryable)</a></td>
372+
<td>memoized custom transforms</td>
373+
<td align="center">✅</td>
374+
</tr>
375+
</tbody></table>

packages/endpoint/README.md

Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -201,36 +201,83 @@ const UserDetail = new Endpoint(({ id }) ⇒ fetch(`/users/${id}`));
201201
const UserDetailNormalized = UserDetail.extend({ schema: User });
202202
```
203203

204-
### Index
205-
206-
```typescript
207-
import { Entity } from '@data-client/normalizr';
208-
import { Index } from '@data-client/endpoint';
209-
210-
class User extends Entity {
211-
id = '';
212-
username = '';\
213-
214-
static indexes = ['username'] as const;
215-
}
216-
217-
const bob = useQuery(User, { username: 'bob' });
218-
219-
// @ts-expect-error Indexes don't fetch, they just retrieve already existing data
220-
const bob = useSuspense(UserIndex, { username: 'bob' });
221-
```
222-
223204
## API
224205

225206
- Networking definition
226207
- [Endpoints](https://dataclient.io/rest/api/Endpoint)
227208
- [Data model](https://dataclient.io/docs/concepts/normalization)
228-
- [Entity](https://dataclient.io/rest/api/Entity), [schema.Entity](https://dataclient.io/rest/api/schema.Entity) mixin
229-
- [Object](https://dataclient.io/rest/api/Object)
230-
- [Array](https://dataclient.io/rest/api/Array)
231-
- [Values](https://dataclient.io/rest/api/Values)
232-
- [All](https://dataclient.io/rest/api/All)
233-
- [Query](https://dataclient.io/rest/api/Query)
234-
- [Collection](https://dataclient.io/rest/api/Collection)
235-
- [Union](https://dataclient.io/rest/api/Union)
236-
- [Invalidate](https://dataclient.io/rest/api/Invalidate)
209+
<table>
210+
<thead>
211+
<tr>
212+
<th>Data Type</th>
213+
<th>Mutable</th>
214+
<th>Schema</th>
215+
<th>Description</th>
216+
<th><a href="https://dataclient.io/rest/api/schema#queryable">Queryable</a></th>
217+
</tr>
218+
</thead>
219+
<tbody><tr>
220+
<td rowSpan="4"><a href="https://en.wikipedia.org/wiki/Object_(computer_science)">Object</a></td>
221+
<td align="center">✅</td>
222+
<td><a href="https://dataclient.io/rest/api/Entity">Entity</a>, <a href="https://dataclient.io/rest/api/schema.Entity">schema.Entity</a> mixin</td>
223+
<td>single <em>unique</em> object</td>
224+
<td align="center">✅</td>
225+
</tr>
226+
<tr>
227+
<td align="center">✅</td>
228+
<td><a href="https://dataclient.io/rest/api/Union">Union(Entity)</a></td>
229+
<td>polymorphic objects (<code>A | B</code>)</td>
230+
<td align="center">✅</td>
231+
</tr>
232+
<tr>
233+
<td align="center">🛑</td>
234+
<td><a href="https://dataclient.io/rest/api/Object">Object</a></td>
235+
<td>statically known keys</td>
236+
<td align="center">🛑</td>
237+
</tr>
238+
<tr>
239+
<td align="center"></td>
240+
<td><a href="https://dataclient.io/rest/api/Invalidate">Invalidate(Entity)</a></td>
241+
<td><a href="https://dataclient.io/docs/concepts/expiry-policy#invalidate-entity">delete an entity</a></td>
242+
<td align="center">🛑</td>
243+
</tr>
244+
<tr>
245+
<td rowSpan="3"><a href="https://en.wikipedia.org/wiki/List_(abstract_data_type)">List</a></td>
246+
<td align="center">✅</td>
247+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Array)</a></td>
248+
<td>growable lists</td>
249+
<td align="center">✅</td>
250+
</tr>
251+
<tr>
252+
<td align="center">🛑</td>
253+
<td><a href="https://dataclient.io/rest/api/Array">Array</a></td>
254+
<td>immutable lists</td>
255+
<td align="center">🛑</td>
256+
</tr>
257+
<tr>
258+
<td align="center">✅</td>
259+
<td><a href="https://dataclient.io/rest/api/All">All</a></td>
260+
<td>list of all entities of a kind</td>
261+
<td align="center">✅</td>
262+
</tr>
263+
<tr>
264+
<td rowSpan="2"><a href="https://en.wikipedia.org/wiki/Associative_array">Map</a></td>
265+
<td align="center">✅</td>
266+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Values)</a></td>
267+
<td>growable maps</td>
268+
<td align="center">✅</td>
269+
</tr>
270+
<tr>
271+
<td align="center">🛑</td>
272+
<td><a href="https://dataclient.io/rest/api/Values">Values</a></td>
273+
<td>immutable maps</td>
274+
<td align="center">🛑</td>
275+
</tr>
276+
<tr>
277+
<td>any</td>
278+
<td align="center"></td>
279+
<td><a href="https://dataclient.io/rest/api/Query">Query(Queryable)</a></td>
280+
<td>memoized custom transforms</td>
281+
<td align="center">✅</td>
282+
</tr>
283+
</tbody></table>

packages/graphql/README.md

Lines changed: 75 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,78 @@ return <ReviewForm onSubmit={data => controller.fetch(createReview, data)} />;
9696
- Networking definition
9797
- [Endpoints](https://dataclient.io/rest/api/Endpoint): [GQLEndpoint](https://dataclient.io/graphql/api/GQLEndpoint)
9898
- [Data model](https://dataclient.io/docs/concepts/normalization)
99-
- [Entity](https://dataclient.io/rest/api/Entity), [schema.Entity](https://dataclient.io/rest/api/schema.Entity) mixin, [GQLEntity](https://dataclient.io/graphql/api/GQLEntity)
100-
- [Object](https://dataclient.io/rest/api/Object)
101-
- [Array](https://dataclient.io/rest/api/Array)
102-
- [Values](https://dataclient.io/rest/api/Values)
103-
- [All](https://dataclient.io/rest/api/All)
104-
- [Collection](https://dataclient.io/rest/api/Collection)
105-
- [Union](https://dataclient.io/rest/api/Union)
106-
- [Invalidate](https://dataclient.io/rest/api/Invalidate)
99+
<table>
100+
<thead>
101+
<tr>
102+
<th>Data Type</th>
103+
<th>Mutable</th>
104+
<th>Schema</th>
105+
<th>Description</th>
106+
<th><a href="https://dataclient.io/rest/api/schema#queryable">Queryable</a></th>
107+
</tr>
108+
</thead>
109+
<tbody><tr>
110+
<td rowSpan="4"><a href="https://en.wikipedia.org/wiki/Object_(computer_science)">Object</a></td>
111+
<td align="center">✅</td>
112+
<td><a href="https://dataclient.io/rest/api/Entity">Entity</a>, <a href="https://dataclient.io/rest/api/schema.Entity">schema.Entity</a> mixin, <a href="https://dataclient.io/graphql/api/GQLEntity">GQLEntity</a></td>
113+
<td>single <em>unique</em> object</td>
114+
<td align="center">✅</td>
115+
</tr>
116+
<tr>
117+
<td align="center">✅</td>
118+
<td><a href="https://dataclient.io/rest/api/Union">Union(Entity)</a></td>
119+
<td>polymorphic objects (<code>A | B</code>)</td>
120+
<td align="center">✅</td>
121+
</tr>
122+
<tr>
123+
<td align="center">🛑</td>
124+
<td><a href="https://dataclient.io/rest/api/Object">Object</a></td>
125+
<td>statically known keys</td>
126+
<td align="center">🛑</td>
127+
</tr>
128+
<tr>
129+
<td align="center"></td>
130+
<td><a href="https://dataclient.io/rest/api/Invalidate">Invalidate(Entity)</a></td>
131+
<td><a href="https://dataclient.io/docs/concepts/expiry-policy#invalidate-entity">delete an entity</a></td>
132+
<td align="center">🛑</td>
133+
</tr>
134+
<tr>
135+
<td rowSpan="3"><a href="https://en.wikipedia.org/wiki/List_(abstract_data_type)">List</a></td>
136+
<td align="center">✅</td>
137+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Array)</a></td>
138+
<td>growable lists</td>
139+
<td align="center">✅</td>
140+
</tr>
141+
<tr>
142+
<td align="center">🛑</td>
143+
<td><a href="https://dataclient.io/rest/api/Array">Array</a></td>
144+
<td>immutable lists</td>
145+
<td align="center">🛑</td>
146+
</tr>
147+
<tr>
148+
<td align="center">✅</td>
149+
<td><a href="https://dataclient.io/rest/api/All">All</a></td>
150+
<td>list of all entities of a kind</td>
151+
<td align="center">✅</td>
152+
</tr>
153+
<tr>
154+
<td rowSpan="2"><a href="https://en.wikipedia.org/wiki/Associative_array">Map</a></td>
155+
<td align="center">✅</td>
156+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Values)</a></td>
157+
<td>growable maps</td>
158+
<td align="center">✅</td>
159+
</tr>
160+
<tr>
161+
<td align="center">🛑</td>
162+
<td><a href="https://dataclient.io/rest/api/Values">Values</a></td>
163+
<td>immutable maps</td>
164+
<td align="center">🛑</td>
165+
</tr>
166+
<tr>
167+
<td>any</td>
168+
<td align="center"></td>
169+
<td><a href="https://dataclient.io/rest/api/Query">Query(Queryable)</a></td>
170+
<td>memoized custom transforms</td>
171+
<td align="center">✅</td>
172+
</tr>
173+
</tbody></table>

packages/normalizr/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,86 @@ is an Array of paths of all entities included in the result.
227227
`memo.buildQueryKey()` builds the input used to denormalize for `query()`. This is exposed
228228
to allow greater flexibility in its usage.
229229

230+
## Schemas
231+
232+
Available from [@data-client/endpoint](https://www.npmjs.com/package/@data-client/endpoint)
233+
234+
<table>
235+
<thead>
236+
<tr>
237+
<th>Data Type</th>
238+
<th>Mutable</th>
239+
<th>Schema</th>
240+
<th>Description</th>
241+
<th><a href="https://dataclient.io/rest/api/schema#queryable">Queryable</a></th>
242+
</tr>
243+
</thead>
244+
<tbody><tr>
245+
<td rowSpan="4"><a href="https://en.wikipedia.org/wiki/Object_(computer_science)">Object</a></td>
246+
<td align="center">✅</td>
247+
<td><a href="https://dataclient.io/rest/api/Entity">Entity</a>, <a href="https://dataclient.io/rest/api/schema.Entity">schema.Entity</a> mixin</td>
248+
<td>single <em>unique</em> object</td>
249+
<td align="center">✅</td>
250+
</tr>
251+
<tr>
252+
<td align="center">✅</td>
253+
<td><a href="https://dataclient.io/rest/api/Union">Union(Entity)</a></td>
254+
<td>polymorphic objects (<code>A | B</code>)</td>
255+
<td align="center">✅</td>
256+
</tr>
257+
<tr>
258+
<td align="center">🛑</td>
259+
<td><a href="https://dataclient.io/rest/api/Object">Object</a></td>
260+
<td>statically known keys</td>
261+
<td align="center">🛑</td>
262+
</tr>
263+
<tr>
264+
<td align="center"></td>
265+
<td><a href="https://dataclient.io/rest/api/Invalidate">Invalidate(Entity)</a></td>
266+
<td><a href="https://dataclient.io/docs/concepts/expiry-policy#invalidate-entity">delete an entity</a></td>
267+
<td align="center">🛑</td>
268+
</tr>
269+
<tr>
270+
<td rowSpan="3"><a href="https://en.wikipedia.org/wiki/List_(abstract_data_type)">List</a></td>
271+
<td align="center">✅</td>
272+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Array)</a></td>
273+
<td>growable lists</td>
274+
<td align="center">✅</td>
275+
</tr>
276+
<tr>
277+
<td align="center">🛑</td>
278+
<td><a href="https://dataclient.io/rest/api/Array">Array</a></td>
279+
<td>immutable lists</td>
280+
<td align="center">🛑</td>
281+
</tr>
282+
<tr>
283+
<td align="center">✅</td>
284+
<td><a href="https://dataclient.io/rest/api/All">All</a></td>
285+
<td>list of all entities of a kind</td>
286+
<td align="center">✅</td>
287+
</tr>
288+
<tr>
289+
<td rowSpan="2"><a href="https://en.wikipedia.org/wiki/Associative_array">Map</a></td>
290+
<td align="center">✅</td>
291+
<td><a href="https://dataclient.io/rest/api/Collection">Collection(Values)</a></td>
292+
<td>growable maps</td>
293+
<td align="center">✅</td>
294+
</tr>
295+
<tr>
296+
<td align="center">🛑</td>
297+
<td><a href="https://dataclient.io/rest/api/Values">Values</a></td>
298+
<td>immutable maps</td>
299+
<td align="center">🛑</td>
300+
</tr>
301+
<tr>
302+
<td>any</td>
303+
<td align="center"></td>
304+
<td><a href="https://dataclient.io/rest/api/Query">Query(Queryable)</a></td>
305+
<td>memoized custom transforms</td>
306+
<td align="center">✅</td>
307+
</tr>
308+
</tbody></table>
309+
230310
## Benchmarks
231311

232312
[Performance compared](https://github.com/reactive/data-client/blob/master/examples/benchmark/README.md) to normalizr package (higher is better):

0 commit comments

Comments
 (0)