Graphql query support for json-logic-js using Lodash methods
npm install json-logic-js-graphql

Exposes immutable useful functions from Lodash to jsonLogic
==, ===, !=, !==, >, >=, <, <=, !!, !, %, +, *, -, /_eq, _gt, _gte, _lt, _lte etc from Lodash methods``bashYarn
$ yarn add json-logic-js-graphql
Usage
`javascriptimport { jsonLogic } from 'json-logic-js-graphql'
const rules = {
_eq: [{ var: 'foo' }, { var: 'bar' }],
}
const data = { foo: 'bar', bar: 'bar' }
jsonLogic.apply(rules, data)
`
GraphQL
jsonLogic's equal operator is
"===" so it can't be used as a GraphQL key.
We expose the eq lodash method as _eq to jsonLogic.`graphql
mutation {
updateResource(
id: "609ce9dbec9fb60004087784"
logic: { _eq: [{ var: "foo" }, "bar"] }
) {
id
}
}`> All Lodash methods exposed with the
_ namespace to avoid overwriting the default jsonLogic's functionality Date functions using momentJs
_gteDate, _gtDate, _lteDate, _ltDate, _eqDate, _getDateexample:
`javascript
const rules = {
_gteDate: [
[{ var: 'from' }, { var: 'to' }],
[364, 'days'],
],
}
const data = { from: '2020-10-01', to: '2021-10-01' }jsonLogic.apply(rules, data)
`Supported Lodash functions:
Can be found here:
Tests
Install dependencies with yarn install and then run the tests yarn test`Bug reports and pull requests are welcome on GitHub at https://github.com/msroot/json-logic-js-graphql. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The library is available as open source under the terms of the MIT License.
Everyone interacting in the json-logic-js-graphql project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.