@orion-js/graphql 2.10.1 → 2.12.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.
@@ -15,19 +15,19 @@ var _graphql = require("graphql");
15
15
 
16
16
  var _schema = require("@orion-js/schema");
17
17
 
18
- var _app = require("@orion-js/app");
19
-
20
18
  var _getScalar = _interopRequireDefault(require("../getType/getScalar"));
21
19
 
20
+ var _isModel = _interopRequireDefault(require("../isModel"));
21
+
22
22
  const storedModelInput = {};
23
23
 
24
- const getModelInput = function (model, fields) {
24
+ const getModelInput = function getField(model, fields) {
25
25
  if (storedModelInput[model.name]) {
26
26
  return storedModelInput[model.name];
27
27
  }
28
28
 
29
29
  storedModelInput[model.name] = new _graphql.GraphQLInputObjectType({
30
- name: model.name + 'Input',
30
+ name: `${model.name}Input`,
31
31
  fields
32
32
  });
33
33
  return storedModelInput[model.name];
@@ -35,13 +35,15 @@ const getModelInput = function (model, fields) {
35
35
 
36
36
  function getParams(type) {
37
37
  if (!type) {
38
- throw new Error(`No type specified`);
38
+ throw new Error('No type specified');
39
39
  }
40
40
 
41
41
  if ((0, _isArray.default)(type)) {
42
42
  const graphQLType = getParams(type[0]);
43
43
  return new _graphql.GraphQLList(graphQLType);
44
- } else if (!type._isFieldType && ((0, _isPlainObject.default)(type) || type instanceof _app.Model)) {
44
+ }
45
+
46
+ if (!type._isFieldType && ((0, _isPlainObject.default)(type) || (0, _isModel.default)(type))) {
45
47
  const model = type.__isModel ? type : type.__model;
46
48
  if (!model || !model.__isModel) throw new Error('Type if not a Model', type);
47
49
  const fields = {};
@@ -53,9 +55,9 @@ function getParams(type) {
53
55
  }
54
56
 
55
57
  return getModelInput(model, fields);
56
- } else {
57
- const schemaType = (0, _schema.getFieldType)(type);
58
- const graphQLType = (0, _getScalar.default)(schemaType);
59
- return graphQLType;
60
58
  }
59
+
60
+ const schemaType = (0, _schema.getFieldType)(type);
61
+ const graphQLType = (0, _getScalar.default)(schemaType);
62
+ return graphQLType;
61
63
  }
@@ -46,7 +46,7 @@ async function _default({
46
46
  type,
47
47
  args,
48
48
 
49
- async resolve(root, params, context) {
49
+ async resolve(_root, params, context) {
50
50
  if (process.env.DEBUG && process.env.DEBUG.split(',').includes('resolver')) {
51
51
  logger.info(`[resolver]: name="${name}"`, {
52
52
  name,
@@ -5,13 +5,13 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.default = _default;
8
+ exports.default = getTypeAsResolver;
9
9
 
10
10
  var _getArgs = _interopRequireDefault(require("../getArgs"));
11
11
 
12
12
  var _errorHandler = _interopRequireDefault(require("../../errorHandler"));
13
13
 
14
- function _default({
14
+ function getTypeAsResolver({
15
15
  resolver,
16
16
  getGraphQLType,
17
17
  options,
@@ -15,12 +15,12 @@ var _graphql = require("graphql");
15
15
 
16
16
  var _schema = require("@orion-js/schema");
17
17
 
18
- var _app = require("@orion-js/app");
19
-
20
18
  var _getScalar = _interopRequireDefault(require("./getScalar"));
21
19
 
22
20
  var _getTypeAsResolver = _interopRequireDefault(require("./getTypeAsResolver"));
23
21
 
22
+ var _isModel = _interopRequireDefault(require("../isModel"));
23
+
24
24
  function getGraphQLType(type, options) {
25
25
  if (!type) {
26
26
  throw new Error('Type is undefined');
@@ -29,7 +29,9 @@ function getGraphQLType(type, options) {
29
29
  if ((0, _isArray.default)(type)) {
30
30
  const graphQLType = getGraphQLType(type[0], options);
31
31
  return new _graphql.GraphQLList(graphQLType);
32
- } else if (!type._isFieldType && ((0, _isPlainObject.default)(type) || type instanceof _app.Model)) {
32
+ }
33
+
34
+ if (!type._isFieldType && ((0, _isPlainObject.default)(type) || (0, _isModel.default)(type))) {
33
35
  const model = type.__isModel ? type : type.__model;
34
36
  if (!model || !model.__isModel) throw new Error('Type if not a Model', type);
35
37
  if (model.graphQLType) return model.graphQLType;
@@ -77,9 +79,9 @@ function getGraphQLType(type, options) {
77
79
  }
78
80
  });
79
81
  return model.graphQLType;
80
- } else {
81
- const schemaType = (0, _schema.getFieldType)(type);
82
- const graphQLType = (0, _getScalar.default)(schemaType);
83
- return graphQLType;
84
82
  }
83
+
84
+ const schemaType = (0, _schema.getFieldType)(type);
85
+ const graphQLType = (0, _getScalar.default)(schemaType);
86
+ return graphQLType;
85
87
  }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = _default;
7
+
8
+ var _app = require("@orion-js/app");
9
+
10
+ function _default(object) {
11
+ return object instanceof _app.Model || object.__isModel;
12
+ }
@@ -42,7 +42,7 @@ async function _default(options) {
42
42
  const handler = apolloServer.createHandler(); // highlight-line
43
43
 
44
44
  const cacheControlCache = apolloOptions.persistedQueries?.cache ? apolloOptions.persistedQueries.cache : new _apolloServerCaching.InMemoryLRUCache();
45
- (0, _app.route)('/graphql', async function (params) {
45
+ (0, _app.route)('/graphql', async params => {
46
46
  const {
47
47
  request,
48
48
  response,
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = _default;
6
+ exports.default = startWebsocket;
7
7
 
8
8
  var _app = require("@orion-js/app");
9
9
 
@@ -15,7 +15,7 @@ var _graphqlSubscriptions = require("graphql-subscriptions");
15
15
 
16
16
  var _pubsub = require("./pubsub");
17
17
 
18
- function _default({
18
+ function startWebsocket({
19
19
  schema
20
20
  }, options) {
21
21
  (0, _pubsub.setPubsub)(options.pubsub || new _graphqlSubscriptions.PubSub());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/graphql",
3
- "version": "2.10.1",
3
+ "version": "2.12.2",
4
4
  "main": "lib/index.js",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",
@@ -11,7 +11,7 @@
11
11
  "test": "jest"
12
12
  },
13
13
  "dependencies": {
14
- "@orion-js/schema": "^2.10.0",
14
+ "@orion-js/schema": "^2.12.2",
15
15
  "apollo-server-core": "3.4.0",
16
16
  "apollo-server-micro": "3.4.0",
17
17
  "deep-sort-object": "^1.0.2",
@@ -26,7 +26,7 @@
26
26
  "@babel/plugin-transform-runtime": "^7.11.0",
27
27
  "@babel/preset-env": "^7.11.0",
28
28
  "@babel/runtime": "^7.11.2",
29
- "@orion-js/app": "^2.10.1",
29
+ "@orion-js/app": "^2.12.2",
30
30
  "babel-jest": "^26.2.2",
31
31
  "graphql": "^15.6.0",
32
32
  "jest": "^26.2.2"
@@ -38,5 +38,5 @@
38
38
  "publishConfig": {
39
39
  "access": "public"
40
40
  },
41
- "gitHead": "fe42a57b41d5fdac3299680bb9d3a6406f878f0a"
41
+ "gitHead": "94f4c8bd9168eed8c3b0363afb1dd0f0bcdd3556"
42
42
  }