@coderich/autograph 0.10.1 → 0.10.2

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/CHANGELOG.md CHANGED
@@ -22,6 +22,7 @@
22
22
  - Exported SchemaDecorator -> Schema
23
23
  - Removed embedded schema SystemEvents (internal emitter also removed)
24
24
  - Removed spread of arguments in QueryBuilder terminal commands (must pass in array)
25
+ - Must pass makeExecutableSchema to Schema constructor
25
26
 
26
27
  ## v0.9.x
27
28
  - Subscriptions API
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.1",
4
+ "version": "0.10.2",
5
5
  "description": "AutoGraph",
6
6
  "keywords": [
7
7
  "graphql",
@@ -30,7 +30,6 @@
30
30
  "ratchet": "ratchet"
31
31
  },
32
32
  "dependencies": {
33
- "@graphql-tools/schema": "^8.3.14",
34
33
  "@hapi/boom": "^9.1.0",
35
34
  "axios": "^0.21.4",
36
35
  "dataloader": "^2.0.0",
@@ -46,6 +45,7 @@
46
45
  },
47
46
  "devDependencies": {
48
47
  "@coderich/ratchet": "^1.5.7",
48
+ "@graphql-tools/schema": "^8.3.14",
49
49
  "graphql": "^15.5.0",
50
50
  "mongodb-memory-server": "^8.7.2",
51
51
  "neo4j-driver": "^4.0.0",
@@ -54,9 +54,6 @@
54
54
  "redis-mock": "^0.47.0",
55
55
  "validator": "^13.7.0"
56
56
  },
57
- "peerDependencies": {
58
- "graphql": "*"
59
- },
60
57
  "repository": {
61
58
  "type": "git",
62
59
  "url": "git@github.com:coderich/autograph.git"
@@ -5,8 +5,8 @@ const { createSystemEvent } = require('../service/event.service');
5
5
 
6
6
  // Export class
7
7
  module.exports = class extends Schema {
8
- constructor(schema, stores) {
9
- super(schema);
8
+ constructor(schema, stores, toExecutableSchema) {
9
+ super(schema, toExecutableSchema);
10
10
 
11
11
  // Create drivers
12
12
  this.drivers = Object.entries(stores).reduce((prev, [key, value]) => {
@@ -2,7 +2,7 @@ const FS = require('fs');
2
2
  const Glob = require('glob');
3
3
  const Merge = require('deepmerge');
4
4
  const { Kind, print, parse, visit } = require('graphql');
5
- const { mergeASTArray, makeExecutableSchema } = require('../../service/graphql.service');
5
+ const { mergeASTArray } = require('../../service/graphql.service');
6
6
  const { deleteKeys } = require('../../service/app.service');
7
7
  const frameworkExt = require('../extension/framework');
8
8
  const typeExt = require('../extension/type');
@@ -24,8 +24,9 @@ const Node = require('./Node');
24
24
  *
25
25
  */
26
26
  module.exports = class Schema extends TypeDefApi {
27
- constructor(schema) {
27
+ constructor(schema, toExecutableSchema) {
28
28
  super();
29
+ this.toExecutableSchema = toExecutableSchema;
29
30
  this.schema = { typeDefs: [], resolvers: {}, schemaDirectives: {} };
30
31
  if (schema) this.mergeSchema(schema);
31
32
  }
@@ -124,7 +125,7 @@ module.exports = class Schema extends TypeDefApi {
124
125
  }
125
126
 
126
127
  makeExecutableSchema() {
127
- return makeExecutableSchema(this.schema);
128
+ return this.toExecutableSchema(this.schema);
128
129
  }
129
130
 
130
131
  toObject() {
@@ -105,32 +105,6 @@ exports.mapPromise = (mixed, fn) => {
105
105
  return Array.isArray(map) ? Promise.all(map) : Promise.resolve(map);
106
106
  };
107
107
 
108
- exports.castCmp = (type, value) => {
109
- switch (type) {
110
- case 'String': {
111
- return `${value}`;
112
- }
113
- case 'Float': case 'Number': {
114
- const num = Number(value);
115
- if (!Number.isNaN(num)) return num;
116
- return value;
117
- }
118
- case 'Int': {
119
- const num = Number(value);
120
- if (!Number.isNaN(num)) return parseInt(value, 10);
121
- return value;
122
- }
123
- case 'Boolean': {
124
- if (value === 'true') return true;
125
- if (value === 'false') return false;
126
- return value;
127
- }
128
- default: {
129
- return value;
130
- }
131
- }
132
- };
133
-
134
108
  exports.objectContaining = (a, b) => {
135
109
  if (a === b) return true;
136
110
 
@@ -1,7 +1,5 @@
1
1
  const { get } = require('lodash');
2
2
  const { Kind, parse, print } = require('graphql');
3
- const { validate } = require('graphql/validation');
4
- const { makeExecutableSchema } = require('@graphql-tools/schema');
5
3
 
6
4
  //
7
5
  const mergePairs = [
@@ -81,13 +79,6 @@ exports.mergeASTArray = (arr) => {
81
79
  }, []).filter(el => !el.deleteFlag);
82
80
  };
83
81
 
84
- exports.validateSchema = (ast) => {
85
- const errs = validate(makeExecutableSchema(ast), ast.typeDefs).filter(({ message }) => message.indexOf('not executable') === -1).map(({ message }) => message);
86
- if (errs.length) throw new Error(errs.join('\n'));
87
- };
88
-
89
- exports.makeExecutableSchema = makeExecutableSchema;
90
-
91
82
  exports.toAST = (a) => {
92
83
  if (typeof a === 'string') return parse(a);
93
84
  if (Array.isArray(a)) return parse(a.map(e => exports.toGQL(e)).join('\n\n'));