dotql
graphql like but query by plain json. No more DSL or AST parsing
A graphql like client and server without graphql DSL, faster parsing.
Built-in implementation for live-query (by ping or/and push)
List of features
- strictly follow graphql but in json, no more DSL parsing
- small in size, all-in-one instead of few heavy weighted packages
- built-in implementation for live-query (by ping or/and push)
Basic Usage
dotql query
client
instead of graphql query
graphqlClient
mutate and watch server data via client
const client = server // watchconst unwatch = clientawait // watch will fill initial data // mutateawait clientawait
use prepared queries for smaller request payload and hiding schema detail
// use prepared query 'getUserById_1' // use prepared mutation 'setUserById_1'await clientawait
create server instance
const server = schema: Queries: getUserById: type: 'User' resolve: async { return ...userDbargs id: args } Mutations: setUserById: type: 'User' resolve: async { return userDbargsid = Object } User: id: type: 'String' count: type: 'Int' blogs: type: 'Object' resolve: async { // batch.load() will auto create new DataLoader(batchLoader) const blogId = await contextbatch return blogId } batchLoader: async _ prepared: Queries: // prepared query with name='getUserById_1' getUserById_1: // { $ref: 'where' } will be replace by prepared query references getUserById: $args: $ref: 'where' id: 1 count: 1 Mutations: setUserById_1: // $refs will pick multiple variables setUserById: $args: $refs: id: 'userId' count: 'count'
trigger resolve to call context.batch.load() which use built-in support of dataloader
// resolve via batchLoaderresult = await client
TODO
Docs
- eTags and channels
- useMutate(func, deps)
Size
dotql client and server
graphql (not yet include apollo or relay)
Contributing
Keep it simple. Keep it minimal. Don't put every single feature just because you can.