0.2.10 โ€ข Published 3 months ago

qman v0.2.10

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

Ultra lightweight query manager

  • super small bundle size ๐Ÿ“ฆ
  • manages deterministic query keys and invocations ๐Ÿ› ๏ธ
  • enhances type safety of existing fetching packages ๐Ÿงช
  • organizes fetching structure into schemas ๐Ÿซ
  • fully tree shake-able ๐ŸŒด

Usage

import { query, schema } from 'qman'
import { use } from 'qman/swr' // or qman/query

// Specifies your getters, can be api route, db handlers, anything that returns a promise
const getAllUsers = () => fetch('your.api/users/')
const getUserById = (id: string) => fetch(`your.api/users/${id}`)

// Specifies a schema that organizes your api, declare multiple schemas based on category
export const users = schema(
  'users',
  query('allUsers', getAllUsers, use), 
  query('byId', getUserById, use),
  query('somePromise', directDBPromiseFn) // note we don't have to use swr/query adapters here
)

// Later in code (usually in different file) use your schema.
users.get('allUsers', [])
users.get('byId', ['exampleId123']) // You get full type-safety here with exact argument names i.e. `[id: string]`

This also ensures your query keys are always unique even if different schemas have same queries. i.e. you can have a schema called users and posts which both ship byId query. You can be sure and safe that even if you mutate / revalidate, it will stay within the schema boundaries and will get type safety according to schema definitions.

Advanced usage

Adds support for advanced query usage, such as

  • firebase
  • subscriptions
  • infinite and paginated queries
  • mutations
  • and more

documentation will come with beta release, will expand on these topics.

0.2.10

3 months ago

0.2.9

4 months ago

0.2.8

4 months ago

0.2.7

4 months ago

0.2.6

4 months ago

0.2.5

4 months ago

0.2.1

4 months ago

0.2.0

4 months ago

0.2.3

4 months ago

0.2.2

4 months ago

0.2.4

4 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago

0.0.27

9 months ago

0.0.26

9 months ago

0.0.25

9 months ago

0.0.24

9 months ago

0.0.23

9 months ago

0.0.22

9 months ago

0.0.21

9 months ago

0.0.20

9 months ago

0.0.19

9 months ago

0.0.18

9 months ago

0.0.17

9 months ago

0.0.16

9 months ago

0.0.15

9 months ago

0.0.14

9 months ago

0.0.13

9 months ago

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago

0.0.0

9 months ago