@graphql-tools/utils 8.2.0-alpha-5cac3eec.0 → 8.2.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/comments.d.ts CHANGED
@@ -17,8 +17,10 @@ export declare function getDescription(node: {
17
17
  }, options?: {
18
18
  commentDescriptions?: boolean;
19
19
  }): string | undefined;
20
+ export declare function getComment(node: {
21
+ loc?: Location;
22
+ }): undefined | string;
20
23
  export declare function getLeadingCommentBlock(node: {
21
- description?: StringValueNode;
22
24
  loc?: Location;
23
25
  }): void | string;
24
26
  export declare function dedentBlockStringValue(rawString: string): string;
package/es5/comments.d.ts CHANGED
@@ -17,8 +17,10 @@ export declare function getDescription(node: {
17
17
  }, options?: {
18
18
  commentDescriptions?: boolean;
19
19
  }): string | undefined;
20
+ export declare function getComment(node: {
21
+ loc?: Location;
22
+ }): undefined | string;
20
23
  export declare function getLeadingCommentBlock(node: {
21
- description?: StringValueNode;
22
24
  loc?: Location;
23
25
  }): void | string;
24
26
  export declare function dedentBlockStringValue(rawString: string): string;
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
2
+ import { SchemaPrintOptions } from './types';
3
+ export declare function fixSchemaAst(schema: GraphQLSchema, options: BuildSchemaOptions & SchemaPrintOptions): GraphQLSchema;
package/es5/index.d.ts CHANGED
@@ -46,3 +46,4 @@ export * from './comments';
46
46
  export * from './collectFields';
47
47
  export * from './inspect';
48
48
  export * from './memoize';
49
+ export * from './fixSchemaAst';
package/es5/index.js CHANGED
@@ -1204,7 +1204,8 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
1204
1204
  var directives = directivesInExtensions
1205
1205
  ? makeDirectiveNodes(schema, directivesInExtensions)
1206
1206
  : ((_a = type.astNode) === null || _a === void 0 ? void 0 : _a.directives) || [];
1207
- if ('specifiedBy' in type && !directives.some(function (directiveNode) { return directiveNode.name.value === 'specifiedBy'; })) {
1207
+ if (type['specifiedByUrl'] &&
1208
+ !directives.some(function (directiveNode) { return directiveNode.name.value === 'specifiedBy'; })) {
1208
1209
  var specifiedByArgs = {
1209
1210
  url: type['specifiedByUrl'],
1210
1211
  };
@@ -1637,7 +1638,7 @@ function collectComment(node) {
1637
1638
  }
1638
1639
  }
1639
1640
  function pushComment(node, entity, field, argument) {
1640
- var comment = getDescription(node, { commentDescriptions: true });
1641
+ var comment = getComment(node);
1641
1642
  if (typeof comment !== 'string' || comment.length === 0) {
1642
1643
  return;
1643
1644
  }
@@ -1800,7 +1801,10 @@ var printDocASTReducer = {
1800
1801
  StringValue: {
1801
1802
  leave: function (_a) {
1802
1803
  var value = _a.value, isBlockString = _a.block;
1803
- return (isBlockString ? printBlockString(value) : JSON.stringify(value));
1804
+ if (isBlockString) {
1805
+ return printBlockString(value);
1806
+ }
1807
+ return JSON.stringify(value);
1804
1808
  },
1805
1809
  },
1806
1810
  BooleanValue: { leave: function (_a) {
@@ -1847,8 +1851,8 @@ var printDocASTReducer = {
1847
1851
  // Type System Definitions
1848
1852
  SchemaDefinition: {
1849
1853
  leave: function (_a) {
1850
- var description = _a.description, directives = _a.directives, operationTypes = _a.operationTypes;
1851
- return wrap('', description, '\n') + join(['schema', join(directives, ' '), block(operationTypes)], ' ');
1854
+ var directives = _a.directives, operationTypes = _a.operationTypes;
1855
+ return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
1852
1856
  },
1853
1857
  },
1854
1858
  OperationTypeDefinition: {
@@ -1859,22 +1863,20 @@ var printDocASTReducer = {
1859
1863
  },
1860
1864
  ScalarTypeDefinition: {
1861
1865
  leave: function (_a) {
1862
- var description = _a.description, name = _a.name, directives = _a.directives;
1863
- return wrap('', description, '\n') + join(['scalar', name, join(directives, ' ')], ' ');
1866
+ var name = _a.name, directives = _a.directives;
1867
+ return join(['scalar', name, join(directives, ' ')], ' ');
1864
1868
  },
1865
1869
  },
1866
1870
  ObjectTypeDefinition: {
1867
1871
  leave: function (_a) {
1868
- var description = _a.description, name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1869
- return wrap('', description, '\n') +
1870
- join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1872
+ var name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1873
+ return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1871
1874
  },
1872
1875
  },
1873
1876
  FieldDefinition: {
1874
1877
  leave: function (_a) {
1875
- var description = _a.description, name = _a.name, args = _a.arguments, type = _a.type, directives = _a.directives;
1876
- return wrap('', description, '\n') +
1877
- name +
1878
+ var name = _a.name, args = _a.arguments, type = _a.type, directives = _a.directives;
1879
+ return name +
1878
1880
  (hasMultilineItems(args)
1879
1881
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
1880
1882
  : wrap('(', join(args, ', '), ')')) +
@@ -1885,46 +1887,44 @@ var printDocASTReducer = {
1885
1887
  },
1886
1888
  InputValueDefinition: {
1887
1889
  leave: function (_a) {
1888
- var description = _a.description, name = _a.name, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
1889
- return wrap('', description, '\n') + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
1890
+ var name = _a.name, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
1891
+ return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
1890
1892
  },
1891
1893
  },
1892
1894
  InterfaceTypeDefinition: {
1893
1895
  leave: function (_a) {
1894
- var description = _a.description, name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1895
- return wrap('', description, '\n') +
1896
- join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1896
+ var name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1897
+ return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1897
1898
  },
1898
1899
  },
1899
1900
  UnionTypeDefinition: {
1900
1901
  leave: function (_a) {
1901
- var description = _a.description, name = _a.name, directives = _a.directives, types = _a.types;
1902
- return wrap('', description, '\n') + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
1902
+ var name = _a.name, directives = _a.directives, types = _a.types;
1903
+ return join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
1903
1904
  },
1904
1905
  },
1905
1906
  EnumTypeDefinition: {
1906
1907
  leave: function (_a) {
1907
- var description = _a.description, name = _a.name, directives = _a.directives, values = _a.values;
1908
- return wrap('', description, '\n') + join(['enum', name, join(directives, ' '), block(values)], ' ');
1908
+ var name = _a.name, directives = _a.directives, values = _a.values;
1909
+ return join(['enum', name, join(directives, ' '), block(values)], ' ');
1909
1910
  },
1910
1911
  },
1911
1912
  EnumValueDefinition: {
1912
1913
  leave: function (_a) {
1913
- var description = _a.description, name = _a.name, directives = _a.directives;
1914
- return wrap('', description, '\n') + join([name, join(directives, ' ')], ' ');
1914
+ var name = _a.name, directives = _a.directives;
1915
+ return join([name, join(directives, ' ')], ' ');
1915
1916
  },
1916
1917
  },
1917
1918
  InputObjectTypeDefinition: {
1918
1919
  leave: function (_a) {
1919
- var description = _a.description, name = _a.name, directives = _a.directives, fields = _a.fields;
1920
- return wrap('', description, '\n') + join(['input', name, join(directives, ' '), block(fields)], ' ');
1920
+ var name = _a.name, directives = _a.directives, fields = _a.fields;
1921
+ return join(['input', name, join(directives, ' '), block(fields)], ' ');
1921
1922
  },
1922
1923
  },
1923
1924
  DirectiveDefinition: {
1924
1925
  leave: function (_a) {
1925
- var description = _a.description, name = _a.name, args = _a.arguments, repeatable = _a.repeatable, locations = _a.locations;
1926
- return wrap('', description, '\n') +
1927
- 'directive @' +
1926
+ var name = _a.name, args = _a.arguments, repeatable = _a.repeatable, locations = _a.locations;
1927
+ return 'directive @' +
1928
1928
  name +
1929
1929
  (hasMultilineItems(args)
1930
1930
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
@@ -1999,10 +1999,13 @@ function getDescription(node, options) {
1999
1999
  return node.description.value;
2000
2000
  }
2001
2001
  if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
2002
- var rawValue = getLeadingCommentBlock(node);
2003
- if (rawValue !== undefined) {
2004
- return dedentBlockStringValue("\n" + rawValue);
2005
- }
2002
+ return getComment(node);
2003
+ }
2004
+ }
2005
+ function getComment(node) {
2006
+ var rawValue = getLeadingCommentBlock(node);
2007
+ if (rawValue !== undefined) {
2008
+ return dedentBlockStringValue("\n" + rawValue);
2006
2009
  }
2007
2010
  }
2008
2011
  function getLeadingCommentBlock(node) {
@@ -4712,6 +4715,25 @@ function withCancel(asyncIteratorLike, onCancel) {
4712
4715
  return asyncIterator;
4713
4716
  }
4714
4717
 
4718
+ function buildFixedSchema(schema, options) {
4719
+ var document = getDocumentNodeFromSchema(schema);
4720
+ return graphql.buildASTSchema(document, tslib.__assign({}, (options || {})));
4721
+ }
4722
+ function fixSchemaAst(schema, options) {
4723
+ // eslint-disable-next-line no-undef-init
4724
+ var schemaWithValidAst = undefined;
4725
+ if (!schema.astNode || !schema.extensionASTNodes) {
4726
+ schemaWithValidAst = buildFixedSchema(schema, options);
4727
+ }
4728
+ if (!schema.astNode && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4729
+ schema.astNode = schemaWithValidAst.astNode;
4730
+ }
4731
+ if (!schema.extensionASTNodes && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4732
+ schema.extensionASTNodes = schemaWithValidAst.extensionASTNodes;
4733
+ }
4734
+ return schema;
4735
+ }
4736
+
4715
4737
  exports.addTypes = addTypes;
4716
4738
  exports.appendObjectFields = appendObjectFields;
4717
4739
  exports.asArray = asArray;
@@ -4742,11 +4764,13 @@ exports.createStub = createStub;
4742
4764
  exports.createVariableNameGenerator = createVariableNameGenerator;
4743
4765
  exports.dedentBlockStringValue = dedentBlockStringValue;
4744
4766
  exports.filterSchema = filterSchema;
4767
+ exports.fixSchemaAst = fixSchemaAst;
4745
4768
  exports.forEachDefaultValue = forEachDefaultValue;
4746
4769
  exports.forEachField = forEachField;
4747
4770
  exports.getArgumentValues = getArgumentValues;
4748
4771
  exports.getBlockStringIndentation = getBlockStringIndentation;
4749
4772
  exports.getBuiltInForStub = getBuiltInForStub;
4773
+ exports.getComment = getComment;
4750
4774
  exports.getDefinedRootType = getDefinedRootType;
4751
4775
  exports.getDeprecatableDirectiveNodes = getDeprecatableDirectiveNodes;
4752
4776
  exports.getDescription = getDescription;
package/es5/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, getOperationAST, getOperationRootType, TypeNameMetaFieldDef } from 'graphql';
1
+ import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, getOperationAST, getOperationRootType, TypeNameMetaFieldDef, buildASTSchema } from 'graphql';
2
2
  import { __spreadArray, __read, __assign, __values, __extends, __awaiter, __generator } from 'tslib';
3
3
 
4
4
  var asArray = function (fns) { return (Array.isArray(fns) ? fns : fns ? [fns] : []); };
@@ -1200,7 +1200,8 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
1200
1200
  var directives = directivesInExtensions
1201
1201
  ? makeDirectiveNodes(schema, directivesInExtensions)
1202
1202
  : ((_a = type.astNode) === null || _a === void 0 ? void 0 : _a.directives) || [];
1203
- if ('specifiedBy' in type && !directives.some(function (directiveNode) { return directiveNode.name.value === 'specifiedBy'; })) {
1203
+ if (type['specifiedByUrl'] &&
1204
+ !directives.some(function (directiveNode) { return directiveNode.name.value === 'specifiedBy'; })) {
1204
1205
  var specifiedByArgs = {
1205
1206
  url: type['specifiedByUrl'],
1206
1207
  };
@@ -1633,7 +1634,7 @@ function collectComment(node) {
1633
1634
  }
1634
1635
  }
1635
1636
  function pushComment(node, entity, field, argument) {
1636
- var comment = getDescription(node, { commentDescriptions: true });
1637
+ var comment = getComment(node);
1637
1638
  if (typeof comment !== 'string' || comment.length === 0) {
1638
1639
  return;
1639
1640
  }
@@ -1796,7 +1797,10 @@ var printDocASTReducer = {
1796
1797
  StringValue: {
1797
1798
  leave: function (_a) {
1798
1799
  var value = _a.value, isBlockString = _a.block;
1799
- return (isBlockString ? printBlockString(value) : JSON.stringify(value));
1800
+ if (isBlockString) {
1801
+ return printBlockString(value);
1802
+ }
1803
+ return JSON.stringify(value);
1800
1804
  },
1801
1805
  },
1802
1806
  BooleanValue: { leave: function (_a) {
@@ -1843,8 +1847,8 @@ var printDocASTReducer = {
1843
1847
  // Type System Definitions
1844
1848
  SchemaDefinition: {
1845
1849
  leave: function (_a) {
1846
- var description = _a.description, directives = _a.directives, operationTypes = _a.operationTypes;
1847
- return wrap('', description, '\n') + join(['schema', join(directives, ' '), block(operationTypes)], ' ');
1850
+ var directives = _a.directives, operationTypes = _a.operationTypes;
1851
+ return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
1848
1852
  },
1849
1853
  },
1850
1854
  OperationTypeDefinition: {
@@ -1855,22 +1859,20 @@ var printDocASTReducer = {
1855
1859
  },
1856
1860
  ScalarTypeDefinition: {
1857
1861
  leave: function (_a) {
1858
- var description = _a.description, name = _a.name, directives = _a.directives;
1859
- return wrap('', description, '\n') + join(['scalar', name, join(directives, ' ')], ' ');
1862
+ var name = _a.name, directives = _a.directives;
1863
+ return join(['scalar', name, join(directives, ' ')], ' ');
1860
1864
  },
1861
1865
  },
1862
1866
  ObjectTypeDefinition: {
1863
1867
  leave: function (_a) {
1864
- var description = _a.description, name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1865
- return wrap('', description, '\n') +
1866
- join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1868
+ var name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1869
+ return join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1867
1870
  },
1868
1871
  },
1869
1872
  FieldDefinition: {
1870
1873
  leave: function (_a) {
1871
- var description = _a.description, name = _a.name, args = _a.arguments, type = _a.type, directives = _a.directives;
1872
- return wrap('', description, '\n') +
1873
- name +
1874
+ var name = _a.name, args = _a.arguments, type = _a.type, directives = _a.directives;
1875
+ return name +
1874
1876
  (hasMultilineItems(args)
1875
1877
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
1876
1878
  : wrap('(', join(args, ', '), ')')) +
@@ -1881,46 +1883,44 @@ var printDocASTReducer = {
1881
1883
  },
1882
1884
  InputValueDefinition: {
1883
1885
  leave: function (_a) {
1884
- var description = _a.description, name = _a.name, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
1885
- return wrap('', description, '\n') + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
1886
+ var name = _a.name, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
1887
+ return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
1886
1888
  },
1887
1889
  },
1888
1890
  InterfaceTypeDefinition: {
1889
1891
  leave: function (_a) {
1890
- var description = _a.description, name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1891
- return wrap('', description, '\n') +
1892
- join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1892
+ var name = _a.name, interfaces = _a.interfaces, directives = _a.directives, fields = _a.fields;
1893
+ return join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' ');
1893
1894
  },
1894
1895
  },
1895
1896
  UnionTypeDefinition: {
1896
1897
  leave: function (_a) {
1897
- var description = _a.description, name = _a.name, directives = _a.directives, types = _a.types;
1898
- return wrap('', description, '\n') + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
1898
+ var name = _a.name, directives = _a.directives, types = _a.types;
1899
+ return join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
1899
1900
  },
1900
1901
  },
1901
1902
  EnumTypeDefinition: {
1902
1903
  leave: function (_a) {
1903
- var description = _a.description, name = _a.name, directives = _a.directives, values = _a.values;
1904
- return wrap('', description, '\n') + join(['enum', name, join(directives, ' '), block(values)], ' ');
1904
+ var name = _a.name, directives = _a.directives, values = _a.values;
1905
+ return join(['enum', name, join(directives, ' '), block(values)], ' ');
1905
1906
  },
1906
1907
  },
1907
1908
  EnumValueDefinition: {
1908
1909
  leave: function (_a) {
1909
- var description = _a.description, name = _a.name, directives = _a.directives;
1910
- return wrap('', description, '\n') + join([name, join(directives, ' ')], ' ');
1910
+ var name = _a.name, directives = _a.directives;
1911
+ return join([name, join(directives, ' ')], ' ');
1911
1912
  },
1912
1913
  },
1913
1914
  InputObjectTypeDefinition: {
1914
1915
  leave: function (_a) {
1915
- var description = _a.description, name = _a.name, directives = _a.directives, fields = _a.fields;
1916
- return wrap('', description, '\n') + join(['input', name, join(directives, ' '), block(fields)], ' ');
1916
+ var name = _a.name, directives = _a.directives, fields = _a.fields;
1917
+ return join(['input', name, join(directives, ' '), block(fields)], ' ');
1917
1918
  },
1918
1919
  },
1919
1920
  DirectiveDefinition: {
1920
1921
  leave: function (_a) {
1921
- var description = _a.description, name = _a.name, args = _a.arguments, repeatable = _a.repeatable, locations = _a.locations;
1922
- return wrap('', description, '\n') +
1923
- 'directive @' +
1922
+ var name = _a.name, args = _a.arguments, repeatable = _a.repeatable, locations = _a.locations;
1923
+ return 'directive @' +
1924
1924
  name +
1925
1925
  (hasMultilineItems(args)
1926
1926
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
@@ -1995,10 +1995,13 @@ function getDescription(node, options) {
1995
1995
  return node.description.value;
1996
1996
  }
1997
1997
  if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
1998
- var rawValue = getLeadingCommentBlock(node);
1999
- if (rawValue !== undefined) {
2000
- return dedentBlockStringValue("\n" + rawValue);
2001
- }
1998
+ return getComment(node);
1999
+ }
2000
+ }
2001
+ function getComment(node) {
2002
+ var rawValue = getLeadingCommentBlock(node);
2003
+ if (rawValue !== undefined) {
2004
+ return dedentBlockStringValue("\n" + rawValue);
2002
2005
  }
2003
2006
  }
2004
2007
  function getLeadingCommentBlock(node) {
@@ -4709,4 +4712,23 @@ function withCancel(asyncIteratorLike, onCancel) {
4709
4712
  return asyncIterator;
4710
4713
  }
4711
4714
 
4712
- export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
4715
+ function buildFixedSchema(schema, options) {
4716
+ var document = getDocumentNodeFromSchema(schema);
4717
+ return buildASTSchema(document, __assign({}, (options || {})));
4718
+ }
4719
+ function fixSchemaAst(schema, options) {
4720
+ // eslint-disable-next-line no-undef-init
4721
+ var schemaWithValidAst = undefined;
4722
+ if (!schema.astNode || !schema.extensionASTNodes) {
4723
+ schemaWithValidAst = buildFixedSchema(schema, options);
4724
+ }
4725
+ if (!schema.astNode && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4726
+ schema.astNode = schemaWithValidAst.astNode;
4727
+ }
4728
+ if (!schema.extensionASTNodes && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4729
+ schema.extensionASTNodes = schemaWithValidAst.extensionASTNodes;
4730
+ }
4731
+ return schema;
4732
+ }
4733
+
4734
+ export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
package/es5/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils/es5",
3
- "version": "8.2.0-alpha-5cac3eec.0",
3
+ "version": "8.2.2",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -0,0 +1,3 @@
1
+ import { GraphQLSchema, BuildSchemaOptions } from 'graphql';
2
+ import { SchemaPrintOptions } from './types';
3
+ export declare function fixSchemaAst(schema: GraphQLSchema, options: BuildSchemaOptions & SchemaPrintOptions): GraphQLSchema;
package/index.d.ts CHANGED
@@ -46,3 +46,4 @@ export * from './comments';
46
46
  export * from './collectFields';
47
47
  export * from './inspect';
48
48
  export * from './memoize';
49
+ export * from './fixSchemaAst';
package/index.js CHANGED
@@ -1013,7 +1013,8 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
1013
1013
  const directives = directivesInExtensions
1014
1014
  ? makeDirectiveNodes(schema, directivesInExtensions)
1015
1015
  : ((_a = type.astNode) === null || _a === void 0 ? void 0 : _a.directives) || [];
1016
- if ('specifiedBy' in type && !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1016
+ if (type['specifiedByUrl'] &&
1017
+ !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1017
1018
  const specifiedByArgs = {
1018
1019
  url: type['specifiedByUrl'],
1019
1020
  };
@@ -1323,7 +1324,7 @@ function collectComment(node) {
1323
1324
  }
1324
1325
  }
1325
1326
  function pushComment(node, entity, field, argument) {
1326
- const comment = getDescription(node, { commentDescriptions: true });
1327
+ const comment = getComment(node);
1327
1328
  if (typeof comment !== 'string' || comment.length === 0) {
1328
1329
  return;
1329
1330
  }
@@ -1459,7 +1460,12 @@ const printDocASTReducer = {
1459
1460
  IntValue: { leave: ({ value }) => value },
1460
1461
  FloatValue: { leave: ({ value }) => value },
1461
1462
  StringValue: {
1462
- leave: ({ value, block: isBlockString }) => (isBlockString ? printBlockString(value) : JSON.stringify(value)),
1463
+ leave: ({ value, block: isBlockString }) => {
1464
+ if (isBlockString) {
1465
+ return printBlockString(value);
1466
+ }
1467
+ return JSON.stringify(value);
1468
+ },
1463
1469
  },
1464
1470
  BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },
1465
1471
  NullValue: { leave: () => 'null' },
@@ -1477,21 +1483,19 @@ const printDocASTReducer = {
1477
1483
  NonNullType: { leave: ({ type }) => type + '!' },
1478
1484
  // Type System Definitions
1479
1485
  SchemaDefinition: {
1480
- leave: ({ description, directives, operationTypes }) => wrap('', description, '\n') + join(['schema', join(directives, ' '), block(operationTypes)], ' '),
1486
+ leave: ({ directives, operationTypes }) => join(['schema', join(directives, ' '), block(operationTypes)], ' '),
1481
1487
  },
1482
1488
  OperationTypeDefinition: {
1483
1489
  leave: ({ operation, type }) => operation + ': ' + type,
1484
1490
  },
1485
1491
  ScalarTypeDefinition: {
1486
- leave: ({ description, name, directives }) => wrap('', description, '\n') + join(['scalar', name, join(directives, ' ')], ' '),
1492
+ leave: ({ name, directives }) => join(['scalar', name, join(directives, ' ')], ' '),
1487
1493
  },
1488
1494
  ObjectTypeDefinition: {
1489
- leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') +
1490
- join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1495
+ leave: ({ name, interfaces, directives, fields }) => join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1491
1496
  },
1492
1497
  FieldDefinition: {
1493
- leave: ({ description, name, arguments: args, type, directives }) => wrap('', description, '\n') +
1494
- name +
1498
+ leave: ({ name, arguments: args, type, directives }) => name +
1495
1499
  (hasMultilineItems(args)
1496
1500
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
1497
1501
  : wrap('(', join(args, ', '), ')')) +
@@ -1500,27 +1504,25 @@ const printDocASTReducer = {
1500
1504
  wrap(' ', join(directives, ' ')),
1501
1505
  },
1502
1506
  InputValueDefinition: {
1503
- leave: ({ description, name, type, defaultValue, directives }) => wrap('', description, '\n') + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
1507
+ leave: ({ name, type, defaultValue, directives }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
1504
1508
  },
1505
1509
  InterfaceTypeDefinition: {
1506
- leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') +
1507
- join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1510
+ leave: ({ name, interfaces, directives, fields }) => join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1508
1511
  },
1509
1512
  UnionTypeDefinition: {
1510
- leave: ({ description, name, directives, types }) => wrap('', description, '\n') + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
1513
+ leave: ({ name, directives, types }) => join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
1511
1514
  },
1512
1515
  EnumTypeDefinition: {
1513
- leave: ({ description, name, directives, values }) => wrap('', description, '\n') + join(['enum', name, join(directives, ' '), block(values)], ' '),
1516
+ leave: ({ name, directives, values }) => join(['enum', name, join(directives, ' '), block(values)], ' '),
1514
1517
  },
1515
1518
  EnumValueDefinition: {
1516
- leave: ({ description, name, directives }) => wrap('', description, '\n') + join([name, join(directives, ' ')], ' '),
1519
+ leave: ({ name, directives }) => join([name, join(directives, ' ')], ' '),
1517
1520
  },
1518
1521
  InputObjectTypeDefinition: {
1519
- leave: ({ description, name, directives, fields }) => wrap('', description, '\n') + join(['input', name, join(directives, ' '), block(fields)], ' '),
1522
+ leave: ({ name, directives, fields }) => join(['input', name, join(directives, ' '), block(fields)], ' '),
1520
1523
  },
1521
1524
  DirectiveDefinition: {
1522
- leave: ({ description, name, arguments: args, repeatable, locations }) => wrap('', description, '\n') +
1523
- 'directive @' +
1525
+ leave: ({ name, arguments: args, repeatable, locations }) => 'directive @' +
1524
1526
  name +
1525
1527
  (hasMultilineItems(args)
1526
1528
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
@@ -1573,10 +1575,13 @@ function getDescription(node, options) {
1573
1575
  return node.description.value;
1574
1576
  }
1575
1577
  if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
1576
- const rawValue = getLeadingCommentBlock(node);
1577
- if (rawValue !== undefined) {
1578
- return dedentBlockStringValue(`\n${rawValue}`);
1579
- }
1578
+ return getComment(node);
1579
+ }
1580
+ }
1581
+ function getComment(node) {
1582
+ const rawValue = getLeadingCommentBlock(node);
1583
+ if (rawValue !== undefined) {
1584
+ return dedentBlockStringValue(`\n${rawValue}`);
1580
1585
  }
1581
1586
  }
1582
1587
  function getLeadingCommentBlock(node) {
@@ -4153,6 +4158,27 @@ function withCancel(asyncIteratorLike, onCancel) {
4153
4158
  return asyncIterator;
4154
4159
  }
4155
4160
 
4161
+ function buildFixedSchema(schema, options) {
4162
+ const document = getDocumentNodeFromSchema(schema);
4163
+ return graphql.buildASTSchema(document, {
4164
+ ...(options || {}),
4165
+ });
4166
+ }
4167
+ function fixSchemaAst(schema, options) {
4168
+ // eslint-disable-next-line no-undef-init
4169
+ let schemaWithValidAst = undefined;
4170
+ if (!schema.astNode || !schema.extensionASTNodes) {
4171
+ schemaWithValidAst = buildFixedSchema(schema, options);
4172
+ }
4173
+ if (!schema.astNode && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4174
+ schema.astNode = schemaWithValidAst.astNode;
4175
+ }
4176
+ if (!schema.extensionASTNodes && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4177
+ schema.extensionASTNodes = schemaWithValidAst.extensionASTNodes;
4178
+ }
4179
+ return schema;
4180
+ }
4181
+
4156
4182
  exports.addTypes = addTypes;
4157
4183
  exports.appendObjectFields = appendObjectFields;
4158
4184
  exports.asArray = asArray;
@@ -4183,11 +4209,13 @@ exports.createStub = createStub;
4183
4209
  exports.createVariableNameGenerator = createVariableNameGenerator;
4184
4210
  exports.dedentBlockStringValue = dedentBlockStringValue;
4185
4211
  exports.filterSchema = filterSchema;
4212
+ exports.fixSchemaAst = fixSchemaAst;
4186
4213
  exports.forEachDefaultValue = forEachDefaultValue;
4187
4214
  exports.forEachField = forEachField;
4188
4215
  exports.getArgumentValues = getArgumentValues;
4189
4216
  exports.getBlockStringIndentation = getBlockStringIndentation;
4190
4217
  exports.getBuiltInForStub = getBuiltInForStub;
4218
+ exports.getComment = getComment;
4191
4219
  exports.getDefinedRootType = getDefinedRootType;
4192
4220
  exports.getDeprecatableDirectiveNodes = getDeprecatableDirectiveNodes;
4193
4221
  exports.getDescription = getDescription;
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, getOperationAST, getOperationRootType, TypeNameMetaFieldDef } from 'graphql';
1
+ import { parse, isNonNullType, GraphQLError, Kind, valueFromAST, print, isObjectType, isListType, isSpecifiedDirective, astFromValue, isSpecifiedScalarType, isIntrospectionType, isInterfaceType, isUnionType, isInputObjectType, isEnumType, isScalarType, GraphQLDeprecatedDirective, specifiedRules, concatAST, validate, buildClientSchema, visit, TokenKind, Source, isTypeSystemDefinitionNode, getNamedType, GraphQLString, GraphQLNonNull, GraphQLList, GraphQLID, GraphQLBoolean, GraphQLFloat, GraphQLInt, GraphQLObjectType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLDirective, GraphQLUnionType, GraphQLEnumType, GraphQLScalarType, isNamedType, getNullableType, isLeafType, GraphQLSchema, isDirective, isCompositeType, doTypesOverlap, getDirectiveValues, GraphQLSkipDirective, GraphQLIncludeDirective, typeFromAST, isAbstractType, getOperationAST, getOperationRootType, TypeNameMetaFieldDef, buildASTSchema } from 'graphql';
2
2
 
3
3
  const asArray = (fns) => (Array.isArray(fns) ? fns : fns ? [fns] : []);
4
4
  const invalidDocRegex = /\.[a-z0-9]+$/i;
@@ -1009,7 +1009,8 @@ function astFromScalarType(type, schema, pathToDirectivesInExtensions) {
1009
1009
  const directives = directivesInExtensions
1010
1010
  ? makeDirectiveNodes(schema, directivesInExtensions)
1011
1011
  : ((_a = type.astNode) === null || _a === void 0 ? void 0 : _a.directives) || [];
1012
- if ('specifiedBy' in type && !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1012
+ if (type['specifiedByUrl'] &&
1013
+ !directives.some(directiveNode => directiveNode.name.value === 'specifiedBy')) {
1013
1014
  const specifiedByArgs = {
1014
1015
  url: type['specifiedByUrl'],
1015
1016
  };
@@ -1319,7 +1320,7 @@ function collectComment(node) {
1319
1320
  }
1320
1321
  }
1321
1322
  function pushComment(node, entity, field, argument) {
1322
- const comment = getDescription(node, { commentDescriptions: true });
1323
+ const comment = getComment(node);
1323
1324
  if (typeof comment !== 'string' || comment.length === 0) {
1324
1325
  return;
1325
1326
  }
@@ -1455,7 +1456,12 @@ const printDocASTReducer = {
1455
1456
  IntValue: { leave: ({ value }) => value },
1456
1457
  FloatValue: { leave: ({ value }) => value },
1457
1458
  StringValue: {
1458
- leave: ({ value, block: isBlockString }) => (isBlockString ? printBlockString(value) : JSON.stringify(value)),
1459
+ leave: ({ value, block: isBlockString }) => {
1460
+ if (isBlockString) {
1461
+ return printBlockString(value);
1462
+ }
1463
+ return JSON.stringify(value);
1464
+ },
1459
1465
  },
1460
1466
  BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },
1461
1467
  NullValue: { leave: () => 'null' },
@@ -1473,21 +1479,19 @@ const printDocASTReducer = {
1473
1479
  NonNullType: { leave: ({ type }) => type + '!' },
1474
1480
  // Type System Definitions
1475
1481
  SchemaDefinition: {
1476
- leave: ({ description, directives, operationTypes }) => wrap('', description, '\n') + join(['schema', join(directives, ' '), block(operationTypes)], ' '),
1482
+ leave: ({ directives, operationTypes }) => join(['schema', join(directives, ' '), block(operationTypes)], ' '),
1477
1483
  },
1478
1484
  OperationTypeDefinition: {
1479
1485
  leave: ({ operation, type }) => operation + ': ' + type,
1480
1486
  },
1481
1487
  ScalarTypeDefinition: {
1482
- leave: ({ description, name, directives }) => wrap('', description, '\n') + join(['scalar', name, join(directives, ' ')], ' '),
1488
+ leave: ({ name, directives }) => join(['scalar', name, join(directives, ' ')], ' '),
1483
1489
  },
1484
1490
  ObjectTypeDefinition: {
1485
- leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') +
1486
- join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1491
+ leave: ({ name, interfaces, directives, fields }) => join(['type', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1487
1492
  },
1488
1493
  FieldDefinition: {
1489
- leave: ({ description, name, arguments: args, type, directives }) => wrap('', description, '\n') +
1490
- name +
1494
+ leave: ({ name, arguments: args, type, directives }) => name +
1491
1495
  (hasMultilineItems(args)
1492
1496
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
1493
1497
  : wrap('(', join(args, ', '), ')')) +
@@ -1496,27 +1500,25 @@ const printDocASTReducer = {
1496
1500
  wrap(' ', join(directives, ' ')),
1497
1501
  },
1498
1502
  InputValueDefinition: {
1499
- leave: ({ description, name, type, defaultValue, directives }) => wrap('', description, '\n') + join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
1503
+ leave: ({ name, type, defaultValue, directives }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
1500
1504
  },
1501
1505
  InterfaceTypeDefinition: {
1502
- leave: ({ description, name, interfaces, directives, fields }) => wrap('', description, '\n') +
1503
- join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1506
+ leave: ({ name, interfaces, directives, fields }) => join(['interface', name, wrap('implements ', join(interfaces, ' & ')), join(directives, ' '), block(fields)], ' '),
1504
1507
  },
1505
1508
  UnionTypeDefinition: {
1506
- leave: ({ description, name, directives, types }) => wrap('', description, '\n') + join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
1509
+ leave: ({ name, directives, types }) => join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
1507
1510
  },
1508
1511
  EnumTypeDefinition: {
1509
- leave: ({ description, name, directives, values }) => wrap('', description, '\n') + join(['enum', name, join(directives, ' '), block(values)], ' '),
1512
+ leave: ({ name, directives, values }) => join(['enum', name, join(directives, ' '), block(values)], ' '),
1510
1513
  },
1511
1514
  EnumValueDefinition: {
1512
- leave: ({ description, name, directives }) => wrap('', description, '\n') + join([name, join(directives, ' ')], ' '),
1515
+ leave: ({ name, directives }) => join([name, join(directives, ' ')], ' '),
1513
1516
  },
1514
1517
  InputObjectTypeDefinition: {
1515
- leave: ({ description, name, directives, fields }) => wrap('', description, '\n') + join(['input', name, join(directives, ' '), block(fields)], ' '),
1518
+ leave: ({ name, directives, fields }) => join(['input', name, join(directives, ' '), block(fields)], ' '),
1516
1519
  },
1517
1520
  DirectiveDefinition: {
1518
- leave: ({ description, name, arguments: args, repeatable, locations }) => wrap('', description, '\n') +
1519
- 'directive @' +
1521
+ leave: ({ name, arguments: args, repeatable, locations }) => 'directive @' +
1520
1522
  name +
1521
1523
  (hasMultilineItems(args)
1522
1524
  ? wrap('(\n', indent(join(args, '\n')), '\n)')
@@ -1569,10 +1571,13 @@ function getDescription(node, options) {
1569
1571
  return node.description.value;
1570
1572
  }
1571
1573
  if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
1572
- const rawValue = getLeadingCommentBlock(node);
1573
- if (rawValue !== undefined) {
1574
- return dedentBlockStringValue(`\n${rawValue}`);
1575
- }
1574
+ return getComment(node);
1575
+ }
1576
+ }
1577
+ function getComment(node) {
1578
+ const rawValue = getLeadingCommentBlock(node);
1579
+ if (rawValue !== undefined) {
1580
+ return dedentBlockStringValue(`\n${rawValue}`);
1576
1581
  }
1577
1582
  }
1578
1583
  function getLeadingCommentBlock(node) {
@@ -4150,4 +4155,25 @@ function withCancel(asyncIteratorLike, onCancel) {
4150
4155
  return asyncIterator;
4151
4156
  }
4152
4157
 
4153
- export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
4158
+ function buildFixedSchema(schema, options) {
4159
+ const document = getDocumentNodeFromSchema(schema);
4160
+ return buildASTSchema(document, {
4161
+ ...(options || {}),
4162
+ });
4163
+ }
4164
+ function fixSchemaAst(schema, options) {
4165
+ // eslint-disable-next-line no-undef-init
4166
+ let schemaWithValidAst = undefined;
4167
+ if (!schema.astNode || !schema.extensionASTNodes) {
4168
+ schemaWithValidAst = buildFixedSchema(schema, options);
4169
+ }
4170
+ if (!schema.astNode && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4171
+ schema.astNode = schemaWithValidAst.astNode;
4172
+ }
4173
+ if (!schema.extensionASTNodes && (schemaWithValidAst === null || schemaWithValidAst === void 0 ? void 0 : schemaWithValidAst.astNode)) {
4174
+ schema.extensionASTNodes = schemaWithValidAst.extensionASTNodes;
4175
+ }
4176
+ return schema;
4177
+ }
4178
+
4179
+ export { AggregateErrorImpl as AggregateError, MapperKind, addTypes, appendObjectFields, asArray, assertSome, astFromArg, astFromDirective, astFromEnumType, astFromEnumValue, astFromField, astFromInputField, astFromInputObjectType, astFromInterfaceType, astFromObjectType, astFromScalarType, astFromSchema, astFromUnionType, astFromValueUntyped, buildOperationNodeForField, checkValidationErrors, collectComment, collectFields, collectSubFields, compareNodes, compareStrings, correctASTNodes, createNamedStub, createStub, createVariableNameGenerator, dedentBlockStringValue, filterSchema, fixSchemaAst, forEachDefaultValue, forEachField, getArgumentValues, getBlockStringIndentation, getBuiltInForStub, getComment, getDefinedRootType, getDeprecatableDirectiveNodes, getDescription, getDirective, getDirectiveInExtensions, getDirectiveNodes, getDirectives, getDirectivesInExtensions, getDocumentNodeFromSchema, getFieldsWithDirectives, getImplementingTypes, getLeadingCommentBlock, getResolversFromSchema, getResponseKeyFromInfo, getRootTypeMap, getRootTypeNames, getRootTypes, healSchema, healTypes, implementsAbstractType, inspect, isAsyncIterable, isDescribable, isDocumentNode, isDocumentString, isNamedStub, isSome, isValidPath, makeDeprecatedDirective, makeDirectiveNode, makeDirectiveNodes, mapAsyncIterator, mapSchema, memoize1, memoize2, memoize2of4, memoize3, memoize4, memoize5, mergeDeep, modifyObjectFields, nodeToString, observableToAsyncIterable, parseGraphQLJSON, parseGraphQLSDL, parseInputValue, parseInputValueLiteral, parseSelectionSet, printComment, printSchemaWithDirectives, printWithComments, pruneSchema, pushComment, relocatedError, removeObjectFields, renameType, resetComments, rewireTypes, selectObjectFields, serializeInputValue, transformCommentsToDescriptions, transformInputValue, updateArgument, validateGraphQlDocuments, valueMatchesCriteria, visitData, visitErrors, visitResult, withCancel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-tools/utils",
3
- "version": "8.2.0-alpha-5cac3eec.0",
3
+ "version": "8.2.2",
4
4
  "description": "Common package containing utils and types for GraphQL tools",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {