@foxify/odin
Advanced tools
Comparing version 0.1.0-beta.12 to 0.1.0-beta.13
@@ -15,2 +15,6 @@ # Changelog | ||
## [v0.1.0-beta.13](https://github.com/foxifyjs/odin/releases/tag/v0.1.0-beta.13) - *(2018-08-21)* | ||
- :beetle: `GraphQL` query bug fix | ||
## [v0.1.0-beta.12](https://github.com/foxifyjs/odin/releases/tag/v0.1.0-beta.12) - *(2018-08-21)* | ||
@@ -17,0 +21,0 @@ |
@@ -28,3 +28,3 @@ /* | ||
var e = this && this.__awaiter || function(e, t, r, n) { | ||
return new (r || (r = Promise))(function(i, s) { | ||
return new (r || (r = Promise))(function(s, i) { | ||
function fulfilled(e) { | ||
@@ -34,3 +34,3 @@ try { | ||
} catch (e) { | ||
s(e); | ||
i(e); | ||
} | ||
@@ -42,7 +42,7 @@ } | ||
} catch (e) { | ||
s(e); | ||
i(e); | ||
} | ||
} | ||
function step(e) { | ||
e.done ? i(e.value) : new r(function(t) { | ||
e.done ? s(e.value) : new r(function(t) { | ||
t(e.value); | ||
@@ -59,4 +59,4 @@ }).then(fulfilled, rejected); | ||
const t = require("graphql"), r = require("../types/Any"), n = require("../utils"), i = (e, n) => { | ||
const s = {}, a = {}; | ||
const t = require("graphql"), r = require("../types/Any"), n = require("../utils"), s = (e, n) => { | ||
const i = {}, a = {}; | ||
for (const o in n) { | ||
@@ -66,3 +66,3 @@ const c = n[o]; | ||
const t = c.toGraphQL(e, o); | ||
s[o] = { | ||
i[o] = { | ||
type: t.field | ||
@@ -74,4 +74,4 @@ }, a[o] = { | ||
} | ||
const u = i(e, c); | ||
s[o] = { | ||
const u = s(e, c); | ||
i[o] = { | ||
type: new t.GraphQLObjectType({ | ||
@@ -89,26 +89,26 @@ name: `${e}_${o}`, | ||
return { | ||
fields: s, | ||
fields: i, | ||
args: a | ||
}; | ||
}, s = e => e.selectionSet.selections.reduce((e, t) => (e.push(t.name.value), e), []), a = (e, i) => { | ||
const s = e => `${e}_ASC`, a = e => `${e}_DESC`, o = (e, t) => { | ||
const i = {}; | ||
}, i = e => e.selectionSet.selections.reduce((e, t) => (e.push(t.name.value), e), []), a = (e, s) => { | ||
const i = e => `${e}_ASC`, a = e => `${e}_DESC`, o = (e, t) => { | ||
const s = {}; | ||
for (const c in e) { | ||
const u = e[c], p = n.array.compact([ t, c ]).join("."); | ||
if (u instanceof r.default) { | ||
const e = s(p); | ||
i[e] = { | ||
const e = i(p); | ||
s[e] = { | ||
value: e | ||
}; | ||
const t = a(p); | ||
i[t] = { | ||
s[t] = { | ||
value: t | ||
}; | ||
} else n.object.forEach(o(e, p), (e, t) => i[t] = e); | ||
} else n.object.forEach(o(e, p), (e, t) => s[t] = e); | ||
} | ||
return i; | ||
return s; | ||
}; | ||
return new t.GraphQLEnumType({ | ||
name: `${e}OrderByInput`, | ||
values: o(i) | ||
values: o(s) | ||
}); | ||
@@ -119,3 +119,3 @@ }, o = e => e && e.toJSON(); | ||
static toGraphQL() { | ||
const r = this.name, c = this._table, u = n.string.pluralize(c, 1), p = i(r, this._schema), d = p.args, l = new t.GraphQLObjectType({ | ||
const r = this.name, c = this._table, u = n.string.pluralize(c, 1), p = s(r, this._schema), l = p.args, d = new t.GraphQLObjectType({ | ||
name: r, | ||
@@ -127,8 +127,11 @@ fields: Object.assign({ | ||
}, p.fields) | ||
}), h = () => this.DB.connection(this.connection).table(this._table), y = { | ||
}), h = () => { | ||
const e = this.DB.connection(this.connection).table(this._table); | ||
return this.softDelete ? e.whereNull(this.DELETED_AT) : e; | ||
}, y = { | ||
[u]: { | ||
type: l, | ||
args: d, | ||
resolve: (t, r, i, a) => e(this, void 0, void 0, function*() { | ||
const e = s(a.fieldNodes[0]); | ||
type: d, | ||
args: l, | ||
resolve: (t, r, s, a) => e(this, void 0, void 0, function*() { | ||
const e = i(a.fieldNodes[0]); | ||
return yield n.object.reduce(r, (e, t, r) => e.where(r, t), h()).first(e); | ||
@@ -138,4 +141,4 @@ }) | ||
[c]: { | ||
type: new t.GraphQLList(l), | ||
args: Object.assign({}, d, { | ||
type: new t.GraphQLList(d), | ||
args: Object.assign({}, l, { | ||
skip: { | ||
@@ -151,4 +154,4 @@ type: t.GraphQLInt | ||
}), | ||
resolve: (t, r, i, a) => e(this, void 0, void 0, function*() { | ||
const e = s(a.fieldNodes[0]); | ||
resolve: (t, r, s, a) => e(this, void 0, void 0, function*() { | ||
const e = i(a.fieldNodes[0]); | ||
let t = h(); | ||
@@ -174,9 +177,9 @@ return this.timestamps && (t = t.orderBy("created_at", "desc")), yield n.object.reduce(r, (e, t, r) => { | ||
name: `${r}QueryInput`, | ||
fields: d | ||
fields: l | ||
}), v = new t.GraphQLInputObjectType({ | ||
name: `${r}Input`, | ||
fields: n.object.omit(d, [ "id", this.CREATED_AT, this.UPDATED_AT, this.DELETED_AT ]) | ||
fields: n.object.omit(l, [ "id", this.CREATED_AT, this.UPDATED_AT, this.DELETED_AT ]) | ||
}), L = { | ||
[`create_${u}`]: { | ||
type: l, | ||
type: d, | ||
args: { | ||
@@ -187,3 +190,3 @@ data: { | ||
}, | ||
resolve: (t, r, n, i) => e(this, void 0, void 0, function*() { | ||
resolve: (t, r, n, s) => e(this, void 0, void 0, function*() { | ||
return o(yield this.create(r.data)); | ||
@@ -199,3 +202,3 @@ }) | ||
}, | ||
resolve: (t, r, n, i) => e(this, void 0, void 0, function*() { | ||
resolve: (t, r, n, s) => e(this, void 0, void 0, function*() { | ||
return yield this.insert(r.data); | ||
@@ -214,3 +217,3 @@ }) | ||
}, | ||
resolve: (t, r, i, s) => e(this, void 0, void 0, function*() { | ||
resolve: (t, r, s, i) => e(this, void 0, void 0, function*() { | ||
return yield n.object.reduce(r.query, (e, t, r) => e.where(r, t), this).update(r.data); | ||
@@ -226,3 +229,3 @@ }) | ||
}, | ||
resolve: (t, r, i, s) => e(this, void 0, void 0, function*() { | ||
resolve: (t, r, s, i) => e(this, void 0, void 0, function*() { | ||
return yield n.object.reduce(r.query, (e, t, r) => e.where(r, t), this).delete(); | ||
@@ -239,3 +242,3 @@ }) | ||
}, | ||
resolve: (t, r, i, s) => e(this, void 0, void 0, function*() { | ||
resolve: (t, r, s, i) => e(this, void 0, void 0, function*() { | ||
return yield n.object.reduce(r.query, (e, t, r) => e.where(r, t), this.withTrashed()).restore(); | ||
@@ -242,0 +245,0 @@ }) |
{ | ||
"name": "@foxify/odin", | ||
"version": "0.1.0-beta.12", | ||
"version": "0.1.0-beta.13", | ||
"description": "Active Record Model", | ||
@@ -5,0 +5,0 @@ "author": "Ardalan Amini <ardalanamini22@gmail.com> [https://github.com/ardalanamini]", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
192957
4364