@luvio/graphql-parser 0.62.2 → 0.63.1

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.
@@ -1,15 +1,12 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
1
  // In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
6
2
 
7
3
  var SYMBOL_TO_STRING_TAG = typeof Symbol === 'function' && Symbol.toStringTag != null ? Symbol.toStringTag : '@@toStringTag';
8
4
 
9
5
  // istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2317')
10
6
  var nodejsCustomInspectSymbol = typeof Symbol === 'function' && typeof Symbol.for === 'function' ? Symbol.for('nodejs.util.inspect.custom') : undefined;
7
+ var nodejsCustomInspectSymbol$1 = nodejsCustomInspectSymbol;
11
8
 
12
- function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
9
+ function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
13
10
  var MAX_ARRAY_LENGTH = 10;
14
11
  var MAX_RECURSIVE_DEPTH = 2;
15
12
  /**
@@ -21,7 +18,7 @@ function inspect(value) {
21
18
  }
22
19
 
23
20
  function formatValue(value, seenValues) {
24
- switch (_typeof(value)) {
21
+ switch (_typeof$2(value)) {
25
22
  case 'string':
26
23
  return JSON.stringify(value);
27
24
 
@@ -106,7 +103,7 @@ function formatArray(array, seenValues) {
106
103
  }
107
104
 
108
105
  function getCustomFn(object) {
109
- var customInspectFn = object[String(nodejsCustomInspectSymbol)];
106
+ var customInspectFn = object[String(nodejsCustomInspectSymbol$1)];
110
107
 
111
108
  if (typeof customInspectFn === 'function') {
112
109
  return customInspectFn;
@@ -167,9 +164,9 @@ function instanceOf(value, constructor) {
167
164
  return false;
168
165
  };
169
166
 
170
- function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
167
+ function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
171
168
 
172
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
169
+ function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
173
170
 
174
171
  /**
175
172
  * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are
@@ -194,7 +191,7 @@ var Source = /*#__PURE__*/function () {
194
191
  } // $FlowFixMe[unsupported-syntax] Flow doesn't support computed properties yet
195
192
 
196
193
 
197
- _createClass(Source, [{
194
+ _createClass$1(Source, [{
198
195
  key: SYMBOL_TO_STRING_TAG,
199
196
  get: function get() {
200
197
  return 'Source';
@@ -282,8 +279,8 @@ function printSourceLocation(source, sourceLocation) {
282
279
 
283
280
  function printPrefixedLines(lines) {
284
281
  var existingLines = lines.filter(function (_ref) {
285
- var _ = _ref[0],
286
- line = _ref[1];
282
+ _ref[0];
283
+ var line = _ref[1];
287
284
  return line !== undefined;
288
285
  });
289
286
  var padLen = Math.max.apply(Math, existingLines.map(function (_ref2) {
@@ -410,19 +407,19 @@ function isObjectLike(value) {
410
407
  return _typeof$1(value) == 'object' && value !== null;
411
408
  }
412
409
 
413
- function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
410
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
414
411
 
415
412
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
416
413
 
417
- function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
414
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
418
415
 
419
- function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
416
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
420
417
 
421
418
  function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
422
419
 
423
420
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
424
421
 
425
- function _possibleConstructorReturn(self, call) { if (call && (_typeof$2(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
422
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
426
423
 
427
424
  function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
428
425
 
@@ -636,7 +633,7 @@ var GraphQLError = /*#__PURE__*/function (_Error) {
636
633
  return _this;
637
634
  }
638
635
 
639
- _createClass$1(GraphQLError, [{
636
+ _createClass(GraphQLError, [{
640
637
  key: "toString",
641
638
  value: function toString() {
642
639
  return printError(this);
@@ -704,8 +701,8 @@ function defineInspect(classObject) {
704
701
  typeof fn === 'function' || invariant(0);
705
702
  classObject.prototype.inspect = fn; // istanbul ignore else (See: 'https://github.com/graphql/graphql-js/issues/2317')
706
703
 
707
- if (nodejsCustomInspectSymbol) {
708
- classObject.prototype[nodejsCustomInspectSymbol] = fn;
704
+ if (nodejsCustomInspectSymbol$1) {
705
+ classObject.prototype[nodejsCustomInspectSymbol$1] = fn;
709
706
  }
710
707
  }
711
708
 
@@ -3487,7 +3484,7 @@ const NODE_KIND_OBJECT_FIELD_SELECTION = 'ObjectFieldSelection';
3487
3484
  const NODE_KIND_SCALAR_FIELD_SELECTION = 'ScalarFieldSelection';
3488
3485
  const NODE_TYPE_CONNECTION = 'Connection';
3489
3486
 
3490
- function transform(node, transformState) {
3487
+ function transform$b(node, transformState) {
3491
3488
  switch (node.kind) {
3492
3489
  case 'Variable':
3493
3490
  transformState.variablesUsed[node.name.value] = true;
@@ -3527,7 +3524,7 @@ function transform(node, transformState) {
3527
3524
  case 'ListValue': {
3528
3525
  const values = [];
3529
3526
  for (var index = 0; index < node.values.length; index++) {
3530
- const value = transform(node.values[index], transformState);
3527
+ const value = transform$b(node.values[index], transformState);
3531
3528
  values.push(value);
3532
3529
  }
3533
3530
  return {
@@ -3540,7 +3537,7 @@ function transform(node, transformState) {
3540
3537
  const result = {};
3541
3538
  fields.forEach((field) => {
3542
3539
  const name = field.name.value;
3543
- const value = transform(field.value, transformState);
3540
+ const value = transform$b(field.value, transformState);
3544
3541
  result[name] = value;
3545
3542
  });
3546
3543
  return {
@@ -3553,9 +3550,9 @@ function transform(node, transformState) {
3553
3550
  }
3554
3551
  }
3555
3552
 
3556
- function transform$1(node, transformState) {
3553
+ function transform$a(node, transformState) {
3557
3554
  const { kind, name: { value: nodeName }, value: nodeValue, } = node;
3558
- const valueNode = transform(nodeValue, transformState);
3555
+ const valueNode = transform$b(nodeValue, transformState);
3559
3556
  return {
3560
3557
  kind,
3561
3558
  name: nodeName,
@@ -3563,7 +3560,7 @@ function transform$1(node, transformState) {
3563
3560
  };
3564
3561
  }
3565
3562
 
3566
- function transform$2(node, transformState) {
3563
+ function transform$9(node, transformState) {
3567
3564
  const { kind, name: { value: nodeName }, arguments: nodeArguments, } = node;
3568
3565
  const ret = {
3569
3566
  kind,
@@ -3573,7 +3570,7 @@ function transform$2(node, transformState) {
3573
3570
  let returnArguments = [];
3574
3571
  for (var index = 0; index < nodeArguments.length; index++) {
3575
3572
  const argumentNode = nodeArguments[index];
3576
- const value = transform$1(argumentNode, transformState);
3573
+ const value = transform$a(argumentNode, transformState);
3577
3574
  returnArguments.push(value);
3578
3575
  }
3579
3576
  ret.arguments = returnArguments;
@@ -3585,7 +3582,7 @@ function isCustomDirective(node) {
3585
3582
  node.name.value === CUSTOM_DIRECTIVE_RESOURCE);
3586
3583
  }
3587
3584
 
3588
- function transform$3(node, transformState) {
3585
+ function transform$8(node, transformState) {
3589
3586
  const { name, alias, arguments: fieldArgs, selectionSet, directives } = node;
3590
3587
  let luvioNode = {
3591
3588
  kind: NODE_KIND_OBJECT_FIELD_SELECTION,
@@ -3604,7 +3601,7 @@ function transform$3(node, transformState) {
3604
3601
  const customDirectiveNode = directives.find(isCustomDirective);
3605
3602
  if (customDirectiveNode === undefined) {
3606
3603
  // transform non client-side directives
3607
- luvioNode.directives = directives.map((directive) => transform$2(directive, transformState));
3604
+ luvioNode.directives = directives.map((directive) => transform$9(directive, transformState));
3608
3605
  }
3609
3606
  else {
3610
3607
  if (customDirectiveNode.name.value === CUSTOM_DIRECTIVE_CONNECTION) {
@@ -3628,7 +3625,7 @@ function transform$3(node, transformState) {
3628
3625
  if (fieldArgs !== undefined && fieldArgs.length > 0) {
3629
3626
  const returnArguments = [];
3630
3627
  for (var index = 0; index < fieldArgs.length; index++) {
3631
- const value = transform$1(fieldArgs[index], transformState);
3628
+ const value = transform$a(fieldArgs[index], transformState);
3632
3629
  returnArguments.push(value);
3633
3630
  }
3634
3631
  luvioNode.arguments = returnArguments;
@@ -3640,19 +3637,19 @@ function transform$3(node, transformState) {
3640
3637
  return luvioNode;
3641
3638
  }
3642
3639
 
3643
- function transform$4(node, transformState) {
3640
+ function transform$7(node, transformState) {
3644
3641
  const { kind, name: { value }, directives, } = node;
3645
3642
  const luvioNode = {
3646
3643
  kind,
3647
3644
  name: value,
3648
3645
  };
3649
3646
  if (directives !== undefined && directives.length > 0) {
3650
- luvioNode.directives = directives.map((directive) => transform$2(directive, transformState));
3647
+ luvioNode.directives = directives.map((directive) => transform$9(directive, transformState));
3651
3648
  }
3652
3649
  return luvioNode;
3653
3650
  }
3654
3651
 
3655
- function transform$5(node, transformState) {
3652
+ function transform$6(node, transformState) {
3656
3653
  const { kind: nodeKind, typeCondition, directives } = node;
3657
3654
  const luvioNode = {
3658
3655
  kind: nodeKind,
@@ -3665,7 +3662,7 @@ function transform$5(node, transformState) {
3665
3662
  };
3666
3663
  }
3667
3664
  if (directives !== undefined && directives.length > 0) {
3668
- luvioNode.directives = directives.map((directive) => transform$2(directive, transformState));
3665
+ luvioNode.directives = directives.map((directive) => transform$9(directive, transformState));
3669
3666
  }
3670
3667
  return luvioNode;
3671
3668
  }
@@ -3676,15 +3673,15 @@ function selectionSetVisitor(ast, luvioSelectionPath, transformState) {
3676
3673
  let selectionNode;
3677
3674
  switch (node.kind) {
3678
3675
  case NODE_KIND_FIELD: {
3679
- const fieldNode = transform$3(node, transformState);
3676
+ const fieldNode = transform$8(node, transformState);
3680
3677
  selectionNode = fieldNode;
3681
3678
  break;
3682
3679
  }
3683
3680
  case NODE_KIND_FRAGMENT_SPREAD:
3684
- selectionNode = transform$4(node, transformState);
3681
+ selectionNode = transform$7(node, transformState);
3685
3682
  break;
3686
3683
  case NODE_KIND_INLINE_FRAGMENT:
3687
- selectionNode = transform$5(node, transformState);
3684
+ selectionNode = transform$6(node, transformState);
3688
3685
  break;
3689
3686
  }
3690
3687
  if (selectionNode !== undefined) {
@@ -3710,7 +3707,7 @@ function selectionSetVisitor(ast, luvioSelectionPath, transformState) {
3710
3707
  visit(ast, visitor);
3711
3708
  }
3712
3709
 
3713
- function transform$6(node) {
3710
+ function transform$5(node) {
3714
3711
  if (isNamedTypeNode(node)) {
3715
3712
  return {
3716
3713
  kind: NODE_KIND_NAMED_TYPE,
@@ -3720,7 +3717,7 @@ function transform$6(node) {
3720
3717
  else if (isListTypeNode(node)) {
3721
3718
  return {
3722
3719
  kind: NODE_KIND_LIST_TYPE,
3723
- type: transform$6(node.type),
3720
+ type: transform$5(node.type),
3724
3721
  };
3725
3722
  }
3726
3723
  else if (isNonNullTypeNode(node)) {
@@ -3738,7 +3735,7 @@ function transform$6(node) {
3738
3735
  kind: NODE_KIND_NON_NULL_TYPE,
3739
3736
  type: {
3740
3737
  kind: NODE_KIND_LIST_TYPE,
3741
- type: transform$6(node.type.type),
3738
+ type: transform$5(node.type.type),
3742
3739
  },
3743
3740
  };
3744
3741
  }
@@ -3751,7 +3748,7 @@ function transform$6(node) {
3751
3748
  }
3752
3749
  }
3753
3750
 
3754
- function transform$7(variableDefinitions, transformState) {
3751
+ function transform$4(variableDefinitions, transformState) {
3755
3752
  const { kind, variable: { kind: variableKind, name: { value: variableName }, }, type, defaultValue, } = variableDefinitions;
3756
3753
  const ret = {
3757
3754
  kind,
@@ -3759,17 +3756,17 @@ function transform$7(variableDefinitions, transformState) {
3759
3756
  kind: variableKind,
3760
3757
  name: variableName,
3761
3758
  },
3762
- type: transform$6(type),
3759
+ type: transform$5(type),
3763
3760
  };
3764
3761
  if (defaultValue !== undefined) {
3765
- const value = transform(defaultValue, transformState);
3762
+ const value = transform$b(defaultValue, transformState);
3766
3763
  ret.defaultValue = value;
3767
3764
  }
3768
3765
  // TODO: transform directives
3769
3766
  return ret;
3770
3767
  }
3771
3768
 
3772
- function transform$8(node) {
3769
+ function transform$3(node) {
3773
3770
  const queryRoot = {
3774
3771
  kind: 'ObjectFieldSelection',
3775
3772
  name: 'query',
@@ -3790,10 +3787,10 @@ function transform$8(node) {
3790
3787
  }
3791
3788
  const { variableDefinitions, directives } = node;
3792
3789
  if (variableDefinitions !== undefined && variableDefinitions.length > 0) {
3793
- operationDefinition.variableDefinitions = variableDefinitions.map((variableDefinition) => transform$7(variableDefinition, transformState));
3790
+ operationDefinition.variableDefinitions = variableDefinitions.map((variableDefinition) => transform$4(variableDefinition, transformState));
3794
3791
  }
3795
3792
  if (directives !== undefined && directives.length > 0) {
3796
- operationDefinition.directives = directives.map((node) => transform$2(node, transformState));
3793
+ operationDefinition.directives = directives.map((node) => transform$9(node, transformState));
3797
3794
  }
3798
3795
  validateVariables(variableDefinitions, transformState);
3799
3796
  return operationDefinition;
@@ -3821,15 +3818,15 @@ function validateVariables(variableDefinitions, transformState) {
3821
3818
  }
3822
3819
  }
3823
3820
 
3824
- function transform$9(node) {
3821
+ function transform$2(node) {
3825
3822
  const { operation } = node;
3826
3823
  if (operation === 'query') {
3827
- return transform$8(node);
3824
+ return transform$3(node);
3828
3825
  }
3829
3826
  throw new Error(`Unsupported ${operation} operation. Only query operation is supported`);
3830
3827
  }
3831
3828
 
3832
- function transform$a(node) {
3829
+ function transform$1(node) {
3833
3830
  const { kind: nodeKind, name: { value: nodeName }, typeCondition: { kind: typeKind, name: { value: typeName }, }, directives, } = node;
3834
3831
  // dummy root node
3835
3832
  const fragmentRoot = {
@@ -3850,21 +3847,21 @@ function transform$a(node) {
3850
3847
  luvioSelections: fragmentRoot.luvioSelections,
3851
3848
  };
3852
3849
  if (directives !== undefined && directives.length > 0) {
3853
- luvioNode.directives = directives.map((node) => transform$2(node, transformState));
3850
+ luvioNode.directives = directives.map((node) => transform$9(node, transformState));
3854
3851
  }
3855
3852
  return luvioNode;
3856
3853
  }
3857
3854
 
3858
- function transform$b(root) {
3855
+ function transform(root) {
3859
3856
  const { kind, definitions } = root;
3860
3857
  const luvioDefinitions = [];
3861
3858
  for (let i = 0; i < definitions.length; i++) {
3862
3859
  const definition = definitions[i];
3863
3860
  if (isOperationDefinitionNode(definition)) {
3864
- luvioDefinitions.push(transform$9(definition));
3861
+ luvioDefinitions.push(transform$2(definition));
3865
3862
  }
3866
3863
  else if (isFragmentDefinitionNode(definition)) {
3867
- luvioDefinitions.push(transform$a(definition));
3864
+ luvioDefinitions.push(transform$1(definition));
3868
3865
  }
3869
3866
  else {
3870
3867
  if (process.env.NODE_ENV !== 'production') {
@@ -3881,7 +3878,7 @@ function transform$b(root) {
3881
3878
  function parseAndVisit(source) {
3882
3879
  // TODO: handle generic <Type>
3883
3880
  const ast = parse(source);
3884
- return transform$b(ast);
3881
+ return transform(ast);
3885
3882
  }
3886
3883
 
3887
- exports.parseAndVisit = parseAndVisit;
3884
+ export { parseAndVisit };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@luvio/graphql-parser",
3
- "version": "0.62.2",
4
- "description": "GraphQL parser for LDS GraphQL adapter",
3
+ "version": "0.63.1",
4
+ "description": "GraphQL parser for Luvio GraphQL adapter support",
5
5
  "main": "dist/luvioGraphqlParser.js",
6
- "module": "true",
6
+ "module": "dist/luvioGraphqlParser.js",
7
7
  "types": "dist/main.d.ts",
8
8
  "license": "MIT",
9
9
  "scripts": {
@@ -13,6 +13,9 @@
13
13
  "test:unit": "jest",
14
14
  "test:debug": "node --inspect-brk ../../node_modules/.bin/jest --runInBand"
15
15
  },
16
+ "dependencies": {
17
+ "graphql": "^15.0.0"
18
+ },
16
19
  "publishConfig": {
17
20
  "access": "public"
18
21
  }
package/rollup.config.js CHANGED
@@ -5,7 +5,7 @@ const luvioGraphqlParserRollupConfig = {
5
5
  input: './src/main.ts',
6
6
  output: {
7
7
  file: 'dist/luvioGraphqlParser.js',
8
- format: 'cjs',
8
+ format: 'esm',
9
9
  },
10
10
 
11
11
  plugins: [
package/scripts/cli.mjs CHANGED
@@ -4,7 +4,7 @@ import { resolve as resolvePath } from 'path';
4
4
 
5
5
  const path = process.argv[2];
6
6
  if (path === undefined) {
7
- throw new Error(`Invalid path "${path}". Usage: "yarn parse PATH_TO_GQL_QUERY.graphql)"`);
7
+ throw new Error(`Invalid path "${path}". Usage: "node scripts/cli.mjs PATH/TO/GQL/QUERY.graphql)"`);
8
8
  }
9
9
 
10
10
  if (existsSync(path) === false) {