This course is no longer maintained and may be out-of-date. While it remains available for reference, its content may not reflect the latest updates, best practices, or supported features.
Push Query for RxDB
For the push query we use an upsert:
const pushQueryBuilder = doc => {const query = `mutation InsertTodo($todo: [todos_insert_input!]!) {insert_todos(objects: $todo,on_conflict: {constraint: todos_pkey,update_columns: [text, isCompleted, deleted, updatedAt]}){returning {id}}}`;const variables = {todo: doc};return {query,variables};};
RxDB will call the above method whenever a document is updated or a new document is created. RxDB will then fire the graphQL query returned along with the variables returned. In the above function the InsertTodo mutation tells hasura to try to insert the row only if a row with the same id
does not already exist. If a row with the same id
exists then Hasura will simply update the columns given in the update_columns
field of that row.
Build apps and APIs 10x faster
Built-in authorization and caching
8x more performant than hand-rolled APIs

