@synthigy/buffer
v0.1.4
Published
WASM-powered transaction buffer for GraphQL - local state management with batched mutations
Maintainers
Readme
@synthigy/buffer
WASM-powered transaction buffer for GraphQL. Local state management with batched mutations.
Installation
npm (with bundler)
npm install @synthigy/bufferimport { connect } from '@synthigy/buffer';
const buffer = await connect('https://api.example.com/graphql');CDN (no bundler)
<script type="module">
import { init, connect } from 'https://cdn.jsdelivr.net/gh/synthigy/[email protected]/dist/index.mjs';
await init({
module: 'https://cdn.jsdelivr.net/gh/synthigy/[email protected]/pkg-web/synthigy_wasm.js',
wasmUrl: 'https://cdn.jsdelivr.net/gh/synthigy/[email protected]/pkg-web/synthigy_wasm_bg.wasm'
});
const buffer = await connect('https://api.example.com/graphql');
</script>Quick Example
import { connect } from '@synthigy/buffer';
// Connect (auto-fetches schema)
const buffer = await connect('https://api.example.com/graphql', {
getAuthToken: async () => localStorage.getItem('token'),
});
// Query
const users = await buffer.search('user', { _limit: 10 }, {
xid: null,
name: null,
roles: { name: null }, // simplified nested syntax
});
// Mutate locally
buffer.sync('user', { xid: 'user-1', name: 'Updated' });
buffer.stack('user', { xid: 'user-1', roles: [{ xid: 'new-role' }] });
buffer.delete('user', 'user-2');
// Commit to server
const result = await buffer.commit();
if (!result.success) {
console.error(result.errors);
}Documentation
See TS_GUIDE.md for complete documentation.
License
MIT
