@coderich/autograph 0.10.4 → 0.10.6

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.10.4",
4
+ "version": "0.10.6",
5
5
  "description": "AutoGraph",
6
6
  "keywords": [
7
7
  "graphql",
@@ -42,14 +42,10 @@
42
42
  "picomatch": "^2.1.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@coderich/ratchet": "^1.5.7",
45
+ "@coderich/ratchet": "^1.5.8",
46
46
  "@graphql-tools/schema": "^9.0.1",
47
47
  "graphql": "^15.5.0",
48
48
  "mongodb-memory-server": "^8.7.2",
49
- "neo4j-driver": "^4.0.0",
50
- "neodb": "^3.0.0",
51
- "redis": "^2.8.0",
52
- "redis-mock": "^0.47.0",
53
49
  "validator": "^13.7.0"
54
50
  },
55
51
  "peerDependencies": {
@@ -11,7 +11,7 @@ exports.finalizeResults = (rs, query) => {
11
11
  $remove: { value: (...args) => resolver.match(model).id(doc.id).remove(...args) },
12
12
  $delete: { value: (...args) => resolver.match(model).id(doc.id).delete(...args) },
13
13
  $lookup: { value: (fieldName, args) => model.getFieldByName(fieldName).resolve(resolver, doc, args) },
14
- // $resolve: { value: (fieldName, args) => model.getFieldByName(fieldName).resolve(resolver, doc, args, true) },
14
+ // $resolve: { value: (fieldName, args) => model.getFieldByName(fieldName).resolve(resolver, doc, args) },
15
15
  });
16
16
  });
17
17
  };
package/src/data/Model.js CHANGED
@@ -65,7 +65,9 @@ module.exports = class extends Model {
65
65
  }).then(rs => finalizeResults(rs, query));
66
66
  }
67
67
 
68
- getShape(crud = 'read', target = 'doc', paths = []) {
68
+ getShape(crud = 'read', target = 'doc', paths = [], depth = 0) {
69
+ if (depth++ > 10) return {}; // Prevent infinite circular references
70
+
69
71
  // Cache check
70
72
  const cacheKey = `${crud}:${target}`;
71
73
  if (this.shapesCache.has(cacheKey)) return this.shapesCache.get(cacheKey);
@@ -113,7 +115,7 @@ module.exports = class extends Model {
113
115
  const actualTo = target === 'input' || target === 'splice' ? from : to;
114
116
  const path = paths.concat(actualTo);
115
117
  const subCrud = crud === 'update' && isArray ? 'create' : crud; // Due to limitation to update embedded array
116
- const subShape = isEmbedded ? modelRef.getShape(subCrud, target, path) : null;
118
+ const subShape = isEmbedded ? modelRef.getShape(subCrud, target, path, depth) : null;
117
119
  const transformers = structureKeys.reduce((prev, struct) => {
118
120
  const structs = structures[struct];
119
121
  if (struct === 'instructs' && structs.length) instructed = true;
@@ -107,8 +107,6 @@ module.exports = (schema) => {
107
107
  `type Query {
108
108
  node(id: ID!): Node
109
109
  ${entityModels.map(model => makeReadAPI(model.getName(), model))}
110
- ${entityModels.map(model => makeReadAPI(`${model.getName()}Create`, model))}
111
- ${entityModels.map(model => makeReadAPI(`${model.getName()}Update`, model))}
112
110
  }`,
113
111
 
114
112
  `type Mutation {
@@ -16,6 +16,7 @@ module.exports = (schema) => {
16
16
  directive @model(
17
17
  id: String # Specify db key (default "id")
18
18
  key: String # Specify db table/collection name
19
+ driver: AutoGraphDriver # External data driver
19
20
  createdAt: String # Specify db key (default "createdAt")
20
21
  updatedAt: String # Specify db key (default "updatedAt")
21
22
  meta: AutoGraphMixed # Custom input "meta" field for mutations
@@ -24,7 +25,6 @@ module.exports = (schema) => {
24
25
  gqlScope: AutoGraphMixed # Dictate how GraphQL API behaves
25
26
  dalScope: AutoGraphMixed # Dictate how the DAL behaves
26
27
  fieldScope: AutoGraphMixed # Dictate how a FIELD may use me
27
- driver: AutoGraphDriver # External data driver
28
28
  authz: AutoGraphAuthzEnum # Access level used for authorization (default: private)
29
29
  namespace: String # Logical grouping of models that can be globbed (useful for authz)
30
30
  ) on OBJECT | INTERFACE
@@ -45,12 +45,12 @@ module.exports = (schema) => {
45
45
 
46
46
  # Pipeline Structure
47
47
  validate: [AutoGraphPipelineEnum!]
48
- instruct: [AutoGraphPipelineEnum!]
48
+ construct: [AutoGraphPipelineEnum!]
49
49
  restruct: [AutoGraphPipelineEnum!]
50
50
  destruct: [AutoGraphPipelineEnum!]
51
- construct: [AutoGraphPipelineEnum!]
52
- transform: [AutoGraphPipelineEnum!]
51
+ instruct: [AutoGraphPipelineEnum!]
53
52
  normalize: [AutoGraphPipelineEnum!]
53
+ transform: [AutoGraphPipelineEnum!]
54
54
  serialize: [AutoGraphPipelineEnum!]
55
55
  deserialize: [AutoGraphPipelineEnum!]
56
56
  ) on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | SCALAR
@@ -10,7 +10,7 @@ const { unravelObject } = require('../service/app.service');
10
10
  */
11
11
  module.exports = class QueryBuilder {
12
12
  constructor(resolver, model) {
13
- this.terminated = false; // Prevent accidental re-use of the QueryBuilder
13
+ // this.terminated = false; // Prevent accidental re-use of the QueryBuilder
14
14
  this.query = new Query({ model, resolver });
15
15
 
16
16
  // Chainable commands
@@ -28,7 +28,7 @@ module.exports = class QueryBuilder {
28
28
  this.after = (cursor) => { this.query.after(cursor); return this; };
29
29
  this.meta = (meta) => { this.query.meta(meta); return this; };
30
30
  this.flags = (flags) => { this.query.flags(flags); return this; };
31
- this.merge = (merge) => { this.query.merge(merge); return this; };
31
+ this.merge = (merge) => { this.query.merge(unravelObject(merge)); return this; };
32
32
  this.batch = (batch) => { this.query.batch(batch); return this; };
33
33
  this.transaction = (txn) => { this.query.transaction(txn); return this; };
34
34
 
@@ -58,10 +58,10 @@ module.exports = class QueryBuilder {
58
58
  }
59
59
 
60
60
  execute(cmd, args) {
61
- // Do not allow re-use
62
- if (this.terminated) return Promise.reject(new Error('This query has already been executed'));
61
+ // // Do not allow re-use
62
+ // if (this.terminated) return Promise.reject(new Error('This query has already been executed'));
63
+ // this.terminated = true;
63
64
 
64
- this.terminated = true;
65
65
  let method, crud, input, flags = {};
66
66
  const { id, where } = this.query.toObject();
67
67
 
@@ -180,12 +180,6 @@ exports.keyPaths = (obj = {}, keys = [], path) => {
180
180
  return Object.entries(obj).reduce((prev, [key, value]) => {
181
181
  const keyPath = path ? `${path}.${key}` : key;
182
182
  if (exports.isPlainObject(value) && Object.keys(value).length) return exports.keyPaths(value, prev, keyPath);
183
-
184
- // if (Array.isArray(value)) {
185
- // const arr = value.filter(v => exports.isPlainObject(v));
186
- // if (arr.length) return _.flatten(arr.map(val => exports.keyPaths(val, prev, keyPath)));
187
- // }
188
-
189
183
  return prev.concat(keyPath);
190
184
  }, keys);
191
185
  };
package/CHANGELOG.md DELETED
@@ -1,41 +0,0 @@
1
- # CHANGELOG
2
-
3
- ## v0.10.x
4
- - Replaced ResultSet -> POJOs
5
- - Removed all $field methods (auto populated)
6
- - Removed .toObject()
7
- - $model $save remove $delete $lookup $cursor $pageInfo
8
- - Removed embedded API completely
9
- - Removed Directives
10
- - embedApi -> no replacement
11
- - enforce -> use pipeline methods
12
- - resolve -> use graphql resolvers
13
- - @value -> use @field.instruct directive
14
- - Removed Model.tform() -> use Model.shapeObject(shape, data)
15
- - Removed Transformer + Rule -> use Pipeline
16
- - Removed many pre-defined rules + transformers
17
- - Moved "validator" to dev dependency -> isEmail
18
- - Added QueryBuilder.resolve() terminal command
19
- - Exported SchemaDecorator -> Schema
20
- - Removed embedded schema SystemEvents (internal emitter also removed)
21
- - Removed spread of arguments in QueryBuilder terminal commands (must pass in array)
22
- - Mutate "merged" instead of "input"
23
- - Validate "payload"
24
-
25
- ## v0.9.x
26
- - Subscriptions API
27
- - postMutation no longer mutates "doc" and adds "result"
28
- - Added onDelete defer option
29
-
30
- ## v0.8.x
31
- - Engine 14+
32
-
33
- ## v0.7.x
34
- - Complete overhaul of Query to Mongo Driver (pagination, sorting, counts, etc)
35
- - Removed countModel Queries from the API (now available as `count` property on `Connetion` types)
36
- - Dropped Neo4J (temporarily)
37
-
38
- ## v0.6.x
39
- - Mongo driver no longer checks for `version` directive
40
- - Models no longer share a Connection type; removing the need to use `... on Model` for GraphQL queries
41
- - Added `@field(connection: Boolean)` parameter to specifically indicate fields that should return a Connection type
package/src/.DS_Store DELETED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file