@foxify/odin
Advanced tools
Comparing version 0.1.0-beta.7 to 0.1.0-beta.8
@@ -15,2 +15,6 @@ # Changelog | ||
## [v0.1.0-beta.8](https://github.com/foxifyjs/odin/releases/tag/v0.1.0-beta.8) - *(2018-08-21)* | ||
- :beetle: `GraphQL` query bug fix | ||
## [v0.1.0-beta.7](https://github.com/foxifyjs/odin/releases/tag/v0.1.0-beta.7) - *(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 u = n[o]; | ||
const t = u.toGraphQL(e, o); | ||
s[o] = { | ||
i[o] = { | ||
type: t.field | ||
@@ -74,4 +74,4 @@ }, a[o] = { | ||
} | ||
const c = i(e, u); | ||
s[o] = { | ||
const c = s(e, u); | ||
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[t.name.value] = 1, 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 u in e) { | ||
const c = e[u], l = n.array.compact([ t, u ]).join("."); | ||
const c = e[u], p = n.array.compact([ t, u ]).join("."); | ||
if (c instanceof r.default) { | ||
const e = s(l); | ||
i[e] = { | ||
const e = i(p); | ||
s[e] = { | ||
value: e | ||
}; | ||
const t = a(l); | ||
i[t] = { | ||
const t = a(p); | ||
s[t] = { | ||
value: t | ||
}; | ||
} else n.object.forEach(o(e, l), (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,25 +119,25 @@ }, o = e => e && e.toJSON(); | ||
static toGraphQL() { | ||
const r = this.name, u = this._table, c = n.string.pluralize(u, 1), l = i(r, this.schema), p = l.fields, d = Object.assign({ | ||
const r = this.name, u = this._table, c = n.string.pluralize(u, 1), p = s(r, this.schema), l = Object.assign({ | ||
id: { | ||
type: t.GraphQLID | ||
} | ||
}, l.args), h = new t.GraphQLObjectType({ | ||
}, p.args), d = new t.GraphQLObjectType({ | ||
name: r, | ||
fields: Object.assign({ | ||
id: { | ||
type: new t.GraphQLNonNull(t.GraphQLID) | ||
type: t.GraphQLID | ||
} | ||
}, p) | ||
}), y = () => this.DB.connection(this.connection).table(this._table), f = { | ||
}, p.fields) | ||
}), h = () => this.DB.connection(this.connection).table(this._table), y = { | ||
[c]: { | ||
type: h, | ||
args: d, | ||
resolve: (t, r, i, a) => e(this, void 0, void 0, function*() { | ||
const e = s(a.fieldNodes[0]); | ||
return yield n.object.reduce(r, (e, t, r) => e.where(r, t), y()).first(e); | ||
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); | ||
}) | ||
}, | ||
[u]: { | ||
type: new t.GraphQLList(h), | ||
args: Object.assign({}, d, { | ||
type: new t.GraphQLList(d), | ||
args: Object.assign({}, l, { | ||
skip: { | ||
@@ -153,5 +153,5 @@ type: t.GraphQLInt | ||
}), | ||
resolve: (t, r, i, a) => e(this, void 0, void 0, function*() { | ||
const e = s(a.fieldNodes[0]); | ||
let t = y(); | ||
resolve: (t, r, s, a) => e(this, void 0, void 0, function*() { | ||
const e = i(a.fieldNodes[0]); | ||
let t = h(); | ||
return this.timestamps && (t = t.orderBy("created_at", "desc")), yield n.object.reduce(r, (e, t, r) => { | ||
@@ -174,14 +174,14 @@ switch (r) { | ||
} | ||
}, v = new t.GraphQLInputObjectType({ | ||
}, f = new t.GraphQLInputObjectType({ | ||
name: `${r}Input`, | ||
fields: l.args | ||
}), L = { | ||
fields: p.args | ||
}), v = { | ||
[`create_${c}`]: { | ||
type: h, | ||
type: d, | ||
args: { | ||
data: { | ||
type: new t.GraphQLNonNull(v) | ||
type: new t.GraphQLNonNull(f) | ||
} | ||
}, | ||
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)); | ||
@@ -194,6 +194,6 @@ }) | ||
data: { | ||
type: new t.GraphQLList(new t.GraphQLNonNull(v)) | ||
type: new t.GraphQLList(new t.GraphQLNonNull(f)) | ||
} | ||
}, | ||
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); | ||
@@ -206,9 +206,9 @@ }) | ||
query: { | ||
type: new t.GraphQLNonNull(v) | ||
type: new t.GraphQLNonNull(f) | ||
}, | ||
data: { | ||
type: new t.GraphQLNonNull(v) | ||
type: new t.GraphQLNonNull(f) | ||
} | ||
}, | ||
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); | ||
@@ -221,6 +221,6 @@ }) | ||
query: { | ||
type: new t.GraphQLNonNull(v) | ||
type: new t.GraphQLNonNull(f) | ||
} | ||
}, | ||
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(); | ||
@@ -230,10 +230,10 @@ }) | ||
}; | ||
return this.softDelete && (L[`restore_${u}`] = { | ||
return this.softDelete && (v[`restore_${u}`] = { | ||
type: t.GraphQLInt, | ||
args: { | ||
query: { | ||
type: new t.GraphQLNonNull(v) | ||
type: new t.GraphQLNonNull(f) | ||
} | ||
}, | ||
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({ | ||
@@ -244,6 +244,6 @@ deleted_at: null | ||
}), { | ||
queries: f, | ||
mutations: L | ||
queries: y, | ||
mutations: v | ||
}; | ||
} | ||
}; |
@@ -34,24 +34,24 @@ /* | ||
exports.default = class Type { | ||
toGraphQL(r, a) { | ||
let t, p, s = e => e; | ||
switch (this._required && (s = (r => new e.GraphQLNonNull(r))), this._type) { | ||
toGraphQL(a, r) { | ||
let t, p; | ||
switch (this._type) { | ||
case "Array": | ||
const n = this.ofType.toGraphQL(r, a); | ||
t = s(new e.GraphQLList(n.field)), p = new e.GraphQLList(n.arg); | ||
const s = this.ofType.toGraphQL(a, r); | ||
t = new e.GraphQLList(s.field), p = new e.GraphQLList(s.arg); | ||
break; | ||
case "Boolean": | ||
t = s(e.GraphQLBoolean), p = e.GraphQLBoolean; | ||
t = e.GraphQLBoolean, p = e.GraphQLBoolean; | ||
break; | ||
case "Number": | ||
t = s(e.GraphQLInt), p = e.GraphQLInt; | ||
t = e.GraphQLInt, p = e.GraphQLInt; | ||
break; | ||
case "Object": | ||
t = s(new e.GraphQLObjectType({ | ||
name: `${r}_${a}`, | ||
t = new e.GraphQLObjectType({ | ||
name: `${a}_${r}`, | ||
fields: {} | ||
})), p = new e.GraphQLInputObjectType({ | ||
name: `${r}_${a}_input`, | ||
}), p = new e.GraphQLInputObjectType({ | ||
name: `${a}_${r}_input`, | ||
fields: {} | ||
@@ -62,7 +62,7 @@ }); | ||
case "ObjectId": | ||
t = s(e.GraphQLID), p = e.GraphQLID; | ||
t = e.GraphQLID, p = e.GraphQLID; | ||
break; | ||
case "String": | ||
t = s(e.GraphQLString), p = e.GraphQLString; | ||
t = e.GraphQLString, p = e.GraphQLString; | ||
} | ||
@@ -69,0 +69,0 @@ return { |
{ | ||
"name": "@foxify/odin", | ||
"version": "0.1.0-beta.7", | ||
"version": "0.1.0-beta.8", | ||
"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
187463