Skip to content

Commit

Permalink
Fix readme, gh action + tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrspartak committed May 17, 2020
1 parent 106bef6 commit 0dddc90
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
7 changes: 2 additions & 5 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '10', '12' ]
name: Node ${{ matrix.node }} sample
name: Node 12 sample
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
node-version: 12
- run: npm install
- run: npm test
env:
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Hasura object mapping library
![Node.js Package](https://github.com/mrspartak/hasura-om/workflows/Node.js%20Package/badge.svg) [![Coverage Status](https://coveralls.io/repos/github/mrspartak/hasura-om/badge.svg?branch=master)](https://coveralls.io/github/mrspartak/hasura-om?branch=master)

# Instalation
```
npm i hasura-om
```

# A problem
We have a microservice infrastructure and need cross-service transactions. One way to do it is to send a graphql query + variables to one service and perform a query there. So this library helps to send more standardized data via JS Objects.
If you know a better way to solve this problem, you are welcome to issues or email.
Expand All @@ -13,6 +18,8 @@ const om = new Hasura({
graphqlUrl: 'your hasura endpoint',
adminSecret: 'your hasura admin secret'
})
//this command loads data from Hasura about tables/fields/keys to build base table fragments for simple queries
await om.init()

//query
let [err, result] = om.query({
Expand Down
33 changes: 33 additions & 0 deletions tests/real_query.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,39 @@ test.serial('delete all records', async (t) => {

t.is(typeof response._om_test.delete, 'object');
t.is(typeof response._om_test_types.delete, 'object');

//ensure that no rows exist
var [err, response] = await orm.query({
_om_test: {},
_om_test_types: {},
});
if (err) throw err;

t.is(response._om_test.length, 0);
t.is(response._om_test_types.length, 0);
});

test.serial('test option flatOne', async (t) => {
let orm = t.context.orm;

var [err, response] = await orm.query({
_om_test: {},
});
if (err) throw err;

t.is(response.length, 0);

var [err, response] = await orm.query(
{
_om_test: {},
},
{
flatOne: false,
},
);
if (err) throw err;

t.is(response._om_test.length, 0);
});

test.serial('add records with transaction', async (t) => {
Expand Down

0 comments on commit 0dddc90

Please sign in to comment.