@coderich/autograph 0.9.8 → 0.9.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@coderich/autograph",
3
3
  "author": "Richard Livolsi (coderich)",
4
- "version": "0.9.8",
4
+ "version": "0.9.11",
5
5
  "description": "AutoGraph",
6
6
  "keywords": [
7
7
  "graphql",
@@ -71,6 +71,10 @@ module.exports = class Resolver {
71
71
  return new DataTransaction(this, parentTxn);
72
72
  }
73
73
 
74
+ disconnect(model) {
75
+ return this.toModelEntity(model).getDriver().disconnect();
76
+ }
77
+
74
78
  resolve(query) {
75
79
  const { model, crud } = query.toObject();
76
80
 
@@ -16,6 +16,10 @@ module.exports = class MongoDriver {
16
16
  return MongoClient.connect(uri, options);
17
17
  }
18
18
 
19
+ disconnect() {
20
+ return this.connection.then(client => client.close());
21
+ }
22
+
19
23
  raw(collection) {
20
24
  return proxyPromise(this.connection.then(client => client.db().collection(collection)));
21
25
  }
@@ -7,8 +7,8 @@ const { validateSchema, makeExecutableSchema, mergeASTSchema, mergeASTArray } =
7
7
  const Node = require('./Node');
8
8
  const Model = require('./Model');
9
9
 
10
- const loadFile = file => FS.readFileSync(Path.resolve(file), 'utf8');
11
- const reqFile = file => require(Path.resolve(file)); // eslint-disable-line global-require,import/no-dynamic-require
10
+ const loadFile = file => FS.readFileSync(file, 'utf8');
11
+ const reqFile = file => require(file); // eslint-disable-line global-require,import/no-dynamic-require
12
12
 
13
13
  module.exports = class Schema extends Node {
14
14
  constructor(schema) {
@@ -154,7 +154,7 @@ module.exports = class QueryResolver {
154
154
  return this.resolver.match(model).match(match).flags(flags).one({ required: true }).then(async (doc) => {
155
155
  await DataService.spliceEmbeddedArray(query, doc, key, from, to);
156
156
 
157
- return createSystemEvent('Mutation', { method: 'splice', query: query.doc(doc).merged(doc) }, async () => {
157
+ return createSystemEvent('Mutation', { method: 'update', query: query.doc(doc).merged(doc) }, async () => {
158
158
  await model.validate(query, doc);
159
159
  const $doc = model.serialize(query, doc, true);
160
160
  return this.resolver.resolve(query.method('updateOne').doc(doc).$doc($doc));
@@ -41,7 +41,7 @@ exports.mergeDeep = (...args) => DeepMerge.all(args, { isMergeableObject: obj =>
41
41
  exports.uniq = arr => [...new Set(arr.map(a => `${a}`))];
42
42
  exports.timeout = ms => new Promise(res => setTimeout(res, ms));
43
43
  exports.hashObject = obj => ObjectHash(obj, { respectType: false, respectFunctionNames: false, respectFunctionProperties: false, unorderedArrays: true, ignoreUnknown: true, replacer: r => (r instanceof ObjectID ? `${r}` : r) });
44
- exports.globToRegex = (glob, options = {}) => PicoMatch.makeRe(glob, { maxLength: 100, ...options, expandRange: (a, b) => `(${FillRange(a, b, { toRegex: true })})` });
44
+ exports.globToRegex = (glob, options = {}) => PicoMatch.makeRe(glob, { ...options, expandRange: (a, b) => `(${FillRange(a, b, { toRegex: true })})` });
45
45
  exports.globToRegexp = (glob, options = {}) => PicoMatch.toRegex(exports.globToRegex(glob, options));
46
46
  exports.toGUID = (model, id) => Buffer.from(`${model},${`${id}`}`).toString('base64');
47
47
  exports.fromGUID = guid => Buffer.from(`${guid}`, 'base64').toString('ascii').split(',');