graphjql

1.1.4 • Public • Published

graphjql

Pure JS(ON) revisitation of GraphQL designed to run on a PostgreSQL and Redis clustered environment.

Don't try this at home.

todo / ideas / brainstorming

q()

Shall $op be always explicit or can it be deducted? (think in Form<add|edit> and Component logic) . get when !$values && $where . add when $values && !$where . edit when $values && $where . remove when $op(remove) => this sucks! . push/pushSync . pop/popSync

add/edit in place with return push/pop in place with return collision detect: if a=>c and b=>c I can not remove "c" hence destroying both a=>c and b=>c (maybe domain logic?) whereMiddlewares: user $token handling to check the root node

redis caching

cache(path): cache the query using the json encoded query as key; when path=>value changes entry is removed from cache how to cache sub branches? scenario: user[id=$token]=>A=>B=>C and just C really changes solution: . using q([query]) + $use(label) . queries are executed sequentially . first queries are always the same so cache is never invalidated . last query uses $use which interpolates $where values using the previous queries array of results ($where: { id: { $use: userQ.id } })

hop jump

. user => tokens => feeds . I need feed descendant of user[id=x] . beings feeds required and logically pushed just for one token . mi ritrovo con tokens che è un array in cui solo un array ha senso . $alimit e $required applicato sulla table association cosi user.tokens è un oggetto e user.tokens.feeds anche, poi con $map prendi solo ultimo

qui si profila l'uso di un limit(map) applicato alle rel; limit=1 l'association feeds e automaticamente torna solo il primo risultato (che esiste) come oggetto => $awheres però:

  1. io devo poter rinominare l'atype del parent (che va saltato) per chiamarla invece come il figlio ultimo
  2. joinare i risultati se sono array A=>[B]=>[C], se salto B ho un array [[C]] da flattenare e tornare come figlio diretto di A

array of operations

. sequence of queries . $use with indexed results to interpolate current query with previous results . begin/commit/rollback?

operators

prefixed with $ to not confuse with associations

. $where, $order, $limit, $offset: applied to model table . $awhere, $aorder, $alimit, $aoffset: applied to association table . $pick([key]): keys to pick . $map({ key => path }): key=>path mapping . $map(key): transform item=>value or [items]=>values . $required(atype | [atypes] | true): discard result if atype or one of atypes or current row is empty . $func({ key => value }): map key to function "key" where "key" can be on of count/distinct/countDistinct/sum/avg/min/max

backend

. explain analyze . trigger on association to check if id1 and id2 exists in respective tables: currently not possible because we can not set dynamic table name in trigger query (at all on sqlite, dirty "execute" construct on postgresql) . binda cache su redis: cache(key) => salva in cache e quando arriva write(invalidator(key)) => refresha cache . omnid: model123 no need to bring around $model that can be interferred by id . while creating invalidators on redis there's no need to bring around the model everywhere . postgresql: add/edit/remove returning in place because we get ids to invalidate mtfkn cache . jsonb: custom data on associations . transactions my friends?

Scenario 1

Scenario: workout =down=> results <=up= user Result wanted: max(result.score) where workout=x and user=y

Scenario 2

Scenario: workout =down=> results Result wanted: avg(each workout.results) Solution: with return(key) you would have just the array of results arrays, aggregated functions should be computed with lowest priority at the end of the queue

models definitions

. models: descrivere siblings, i.e se user=>company allora user=>tax dove company e tax sono sibling entrambi mutualmente required . presenters: FormPresenter, SelectPresenter, Multiselected presenter embeddabili

con triggers posso verificare un meta jsonb che descrive i permessi sulle associations? . quando traverso => ogni volta prima di entrare in type posso applicare filtro utente/gruppi . insert transaction . vedo

add: permetti creazione intero branch add/edit con where come get: ritorna intero branch creato

Security

. queries defined server side and hashed: if client query hash does not match allowed queries hashes then refuse to run . checks at startup (database, redis, models consistencies, loops in associations) . redis + rejson

Readme

Keywords

none

Package Sidebar

Install

npm i graphjql

Weekly Downloads

3

Version

1.1.4

License

MIT

Last publish

Collaborators

  • damianobarbati