@coderich/autograph 0.9.7 → 0.9.10

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.7",
4
+ "version": "0.9.10",
5
5
  "description": "AutoGraph",
6
6
  "keywords": [
7
7
  "graphql",
@@ -175,4 +175,9 @@ module.exports = class Field extends Node {
175
175
  type = this.isArray() ? `[${type}${this.isArrayElementRequired() ? '!' : ''}]` : type;
176
176
  return `${type}${req}`;
177
177
  }
178
+
179
+ getSubscriptionType() {
180
+ if (this.isFKReference()) return this.isArray() ? '[ID]' : 'ID';
181
+ return this.getGQLType();
182
+ }
178
183
  };
@@ -90,7 +90,7 @@ module.exports = (schema) => {
90
90
  }
91
91
 
92
92
  type ${model.getName()}SubscriptionPayloadEventData {
93
- ${getGQLWhereFields(model).map(field => `${field.getName()}: ${field.isFKReference() ? 'ID' : field.getGQLType()}`)}
93
+ ${getGQLWhereFields(model).map(field => `${field.getName()}: ${field.getSubscriptionType()}`)}
94
94
  }
95
95
 
96
96
  interface ${model.getName()}SubscriptionQuery {
@@ -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(',');