@graphql-tools/utils 8.2.1 → 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 +3 -1
- package/es5/comments.d.ts +3 -1
- package/es5/index.js +35 -32
- package/es5/index.mjs +35 -33
- package/es5/package.json +1 -1
- package/index.js +26 -21
- package/index.mjs +26 -22
- package/package.json +1 -1
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;
|
package/es5/index.js
CHANGED
|
@@ -1638,7 +1638,7 @@ function collectComment(node) {
|
|
|
1638
1638
|
}
|
|
1639
1639
|
}
|
|
1640
1640
|
function pushComment(node, entity, field, argument) {
|
|
1641
|
-
var comment =
|
|
1641
|
+
var comment = getComment(node);
|
|
1642
1642
|
if (typeof comment !== 'string' || comment.length === 0) {
|
|
1643
1643
|
return;
|
|
1644
1644
|
}
|
|
@@ -1801,7 +1801,10 @@ var printDocASTReducer = {
|
|
|
1801
1801
|
StringValue: {
|
|
1802
1802
|
leave: function (_a) {
|
|
1803
1803
|
var value = _a.value, isBlockString = _a.block;
|
|
1804
|
-
|
|
1804
|
+
if (isBlockString) {
|
|
1805
|
+
return printBlockString(value);
|
|
1806
|
+
}
|
|
1807
|
+
return JSON.stringify(value);
|
|
1805
1808
|
},
|
|
1806
1809
|
},
|
|
1807
1810
|
BooleanValue: { leave: function (_a) {
|
|
@@ -1848,8 +1851,8 @@ var printDocASTReducer = {
|
|
|
1848
1851
|
// Type System Definitions
|
|
1849
1852
|
SchemaDefinition: {
|
|
1850
1853
|
leave: function (_a) {
|
|
1851
|
-
var
|
|
1852
|
-
return
|
|
1854
|
+
var directives = _a.directives, operationTypes = _a.operationTypes;
|
|
1855
|
+
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
1853
1856
|
},
|
|
1854
1857
|
},
|
|
1855
1858
|
OperationTypeDefinition: {
|
|
@@ -1860,22 +1863,20 @@ var printDocASTReducer = {
|
|
|
1860
1863
|
},
|
|
1861
1864
|
ScalarTypeDefinition: {
|
|
1862
1865
|
leave: function (_a) {
|
|
1863
|
-
var
|
|
1864
|
-
return
|
|
1866
|
+
var name = _a.name, directives = _a.directives;
|
|
1867
|
+
return join(['scalar', name, join(directives, ' ')], ' ');
|
|
1865
1868
|
},
|
|
1866
1869
|
},
|
|
1867
1870
|
ObjectTypeDefinition: {
|
|
1868
1871
|
leave: function (_a) {
|
|
1869
|
-
var
|
|
1870
|
-
return wrap('',
|
|
1871
|
-
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)], ' ');
|
|
1872
1874
|
},
|
|
1873
1875
|
},
|
|
1874
1876
|
FieldDefinition: {
|
|
1875
1877
|
leave: function (_a) {
|
|
1876
|
-
var
|
|
1877
|
-
return
|
|
1878
|
-
name +
|
|
1878
|
+
var name = _a.name, args = _a.arguments, type = _a.type, directives = _a.directives;
|
|
1879
|
+
return name +
|
|
1879
1880
|
(hasMultilineItems(args)
|
|
1880
1881
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
1881
1882
|
: wrap('(', join(args, ', '), ')')) +
|
|
@@ -1886,46 +1887,44 @@ var printDocASTReducer = {
|
|
|
1886
1887
|
},
|
|
1887
1888
|
InputValueDefinition: {
|
|
1888
1889
|
leave: function (_a) {
|
|
1889
|
-
var
|
|
1890
|
-
return
|
|
1890
|
+
var name = _a.name, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
|
|
1891
|
+
return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
|
|
1891
1892
|
},
|
|
1892
1893
|
},
|
|
1893
1894
|
InterfaceTypeDefinition: {
|
|
1894
1895
|
leave: function (_a) {
|
|
1895
|
-
var
|
|
1896
|
-
return wrap('',
|
|
1897
|
-
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)], ' ');
|
|
1898
1898
|
},
|
|
1899
1899
|
},
|
|
1900
1900
|
UnionTypeDefinition: {
|
|
1901
1901
|
leave: function (_a) {
|
|
1902
|
-
var
|
|
1903
|
-
return
|
|
1902
|
+
var name = _a.name, directives = _a.directives, types = _a.types;
|
|
1903
|
+
return join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
|
|
1904
1904
|
},
|
|
1905
1905
|
},
|
|
1906
1906
|
EnumTypeDefinition: {
|
|
1907
1907
|
leave: function (_a) {
|
|
1908
|
-
var
|
|
1909
|
-
return
|
|
1908
|
+
var name = _a.name, directives = _a.directives, values = _a.values;
|
|
1909
|
+
return join(['enum', name, join(directives, ' '), block(values)], ' ');
|
|
1910
1910
|
},
|
|
1911
1911
|
},
|
|
1912
1912
|
EnumValueDefinition: {
|
|
1913
1913
|
leave: function (_a) {
|
|
1914
|
-
var
|
|
1915
|
-
return
|
|
1914
|
+
var name = _a.name, directives = _a.directives;
|
|
1915
|
+
return join([name, join(directives, ' ')], ' ');
|
|
1916
1916
|
},
|
|
1917
1917
|
},
|
|
1918
1918
|
InputObjectTypeDefinition: {
|
|
1919
1919
|
leave: function (_a) {
|
|
1920
|
-
var
|
|
1921
|
-
return
|
|
1920
|
+
var name = _a.name, directives = _a.directives, fields = _a.fields;
|
|
1921
|
+
return join(['input', name, join(directives, ' '), block(fields)], ' ');
|
|
1922
1922
|
},
|
|
1923
1923
|
},
|
|
1924
1924
|
DirectiveDefinition: {
|
|
1925
1925
|
leave: function (_a) {
|
|
1926
|
-
var
|
|
1927
|
-
return
|
|
1928
|
-
'directive @' +
|
|
1926
|
+
var name = _a.name, args = _a.arguments, repeatable = _a.repeatable, locations = _a.locations;
|
|
1927
|
+
return 'directive @' +
|
|
1929
1928
|
name +
|
|
1930
1929
|
(hasMultilineItems(args)
|
|
1931
1930
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
@@ -2000,10 +1999,13 @@ function getDescription(node, options) {
|
|
|
2000
1999
|
return node.description.value;
|
|
2001
2000
|
}
|
|
2002
2001
|
if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2002
|
+
return getComment(node);
|
|
2003
|
+
}
|
|
2004
|
+
}
|
|
2005
|
+
function getComment(node) {
|
|
2006
|
+
var rawValue = getLeadingCommentBlock(node);
|
|
2007
|
+
if (rawValue !== undefined) {
|
|
2008
|
+
return dedentBlockStringValue("\n" + rawValue);
|
|
2007
2009
|
}
|
|
2008
2010
|
}
|
|
2009
2011
|
function getLeadingCommentBlock(node) {
|
|
@@ -4768,6 +4770,7 @@ exports.forEachField = forEachField;
|
|
|
4768
4770
|
exports.getArgumentValues = getArgumentValues;
|
|
4769
4771
|
exports.getBlockStringIndentation = getBlockStringIndentation;
|
|
4770
4772
|
exports.getBuiltInForStub = getBuiltInForStub;
|
|
4773
|
+
exports.getComment = getComment;
|
|
4771
4774
|
exports.getDefinedRootType = getDefinedRootType;
|
|
4772
4775
|
exports.getDeprecatableDirectiveNodes = getDeprecatableDirectiveNodes;
|
|
4773
4776
|
exports.getDescription = getDescription;
|
package/es5/index.mjs
CHANGED
|
@@ -1634,7 +1634,7 @@ function collectComment(node) {
|
|
|
1634
1634
|
}
|
|
1635
1635
|
}
|
|
1636
1636
|
function pushComment(node, entity, field, argument) {
|
|
1637
|
-
var comment =
|
|
1637
|
+
var comment = getComment(node);
|
|
1638
1638
|
if (typeof comment !== 'string' || comment.length === 0) {
|
|
1639
1639
|
return;
|
|
1640
1640
|
}
|
|
@@ -1797,7 +1797,10 @@ var printDocASTReducer = {
|
|
|
1797
1797
|
StringValue: {
|
|
1798
1798
|
leave: function (_a) {
|
|
1799
1799
|
var value = _a.value, isBlockString = _a.block;
|
|
1800
|
-
|
|
1800
|
+
if (isBlockString) {
|
|
1801
|
+
return printBlockString(value);
|
|
1802
|
+
}
|
|
1803
|
+
return JSON.stringify(value);
|
|
1801
1804
|
},
|
|
1802
1805
|
},
|
|
1803
1806
|
BooleanValue: { leave: function (_a) {
|
|
@@ -1844,8 +1847,8 @@ var printDocASTReducer = {
|
|
|
1844
1847
|
// Type System Definitions
|
|
1845
1848
|
SchemaDefinition: {
|
|
1846
1849
|
leave: function (_a) {
|
|
1847
|
-
var
|
|
1848
|
-
return
|
|
1850
|
+
var directives = _a.directives, operationTypes = _a.operationTypes;
|
|
1851
|
+
return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
|
|
1849
1852
|
},
|
|
1850
1853
|
},
|
|
1851
1854
|
OperationTypeDefinition: {
|
|
@@ -1856,22 +1859,20 @@ var printDocASTReducer = {
|
|
|
1856
1859
|
},
|
|
1857
1860
|
ScalarTypeDefinition: {
|
|
1858
1861
|
leave: function (_a) {
|
|
1859
|
-
var
|
|
1860
|
-
return
|
|
1862
|
+
var name = _a.name, directives = _a.directives;
|
|
1863
|
+
return join(['scalar', name, join(directives, ' ')], ' ');
|
|
1861
1864
|
},
|
|
1862
1865
|
},
|
|
1863
1866
|
ObjectTypeDefinition: {
|
|
1864
1867
|
leave: function (_a) {
|
|
1865
|
-
var
|
|
1866
|
-
return wrap('',
|
|
1867
|
-
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)], ' ');
|
|
1868
1870
|
},
|
|
1869
1871
|
},
|
|
1870
1872
|
FieldDefinition: {
|
|
1871
1873
|
leave: function (_a) {
|
|
1872
|
-
var
|
|
1873
|
-
return
|
|
1874
|
-
name +
|
|
1874
|
+
var name = _a.name, args = _a.arguments, type = _a.type, directives = _a.directives;
|
|
1875
|
+
return name +
|
|
1875
1876
|
(hasMultilineItems(args)
|
|
1876
1877
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
1877
1878
|
: wrap('(', join(args, ', '), ')')) +
|
|
@@ -1882,46 +1883,44 @@ var printDocASTReducer = {
|
|
|
1882
1883
|
},
|
|
1883
1884
|
InputValueDefinition: {
|
|
1884
1885
|
leave: function (_a) {
|
|
1885
|
-
var
|
|
1886
|
-
return
|
|
1886
|
+
var name = _a.name, type = _a.type, defaultValue = _a.defaultValue, directives = _a.directives;
|
|
1887
|
+
return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
|
|
1887
1888
|
},
|
|
1888
1889
|
},
|
|
1889
1890
|
InterfaceTypeDefinition: {
|
|
1890
1891
|
leave: function (_a) {
|
|
1891
|
-
var
|
|
1892
|
-
return wrap('',
|
|
1893
|
-
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)], ' ');
|
|
1894
1894
|
},
|
|
1895
1895
|
},
|
|
1896
1896
|
UnionTypeDefinition: {
|
|
1897
1897
|
leave: function (_a) {
|
|
1898
|
-
var
|
|
1899
|
-
return
|
|
1898
|
+
var name = _a.name, directives = _a.directives, types = _a.types;
|
|
1899
|
+
return join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' ');
|
|
1900
1900
|
},
|
|
1901
1901
|
},
|
|
1902
1902
|
EnumTypeDefinition: {
|
|
1903
1903
|
leave: function (_a) {
|
|
1904
|
-
var
|
|
1905
|
-
return
|
|
1904
|
+
var name = _a.name, directives = _a.directives, values = _a.values;
|
|
1905
|
+
return join(['enum', name, join(directives, ' '), block(values)], ' ');
|
|
1906
1906
|
},
|
|
1907
1907
|
},
|
|
1908
1908
|
EnumValueDefinition: {
|
|
1909
1909
|
leave: function (_a) {
|
|
1910
|
-
var
|
|
1911
|
-
return
|
|
1910
|
+
var name = _a.name, directives = _a.directives;
|
|
1911
|
+
return join([name, join(directives, ' ')], ' ');
|
|
1912
1912
|
},
|
|
1913
1913
|
},
|
|
1914
1914
|
InputObjectTypeDefinition: {
|
|
1915
1915
|
leave: function (_a) {
|
|
1916
|
-
var
|
|
1917
|
-
return
|
|
1916
|
+
var name = _a.name, directives = _a.directives, fields = _a.fields;
|
|
1917
|
+
return join(['input', name, join(directives, ' '), block(fields)], ' ');
|
|
1918
1918
|
},
|
|
1919
1919
|
},
|
|
1920
1920
|
DirectiveDefinition: {
|
|
1921
1921
|
leave: function (_a) {
|
|
1922
|
-
var
|
|
1923
|
-
return
|
|
1924
|
-
'directive @' +
|
|
1922
|
+
var name = _a.name, args = _a.arguments, repeatable = _a.repeatable, locations = _a.locations;
|
|
1923
|
+
return 'directive @' +
|
|
1925
1924
|
name +
|
|
1926
1925
|
(hasMultilineItems(args)
|
|
1927
1926
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
@@ -1996,10 +1995,13 @@ function getDescription(node, options) {
|
|
|
1996
1995
|
return node.description.value;
|
|
1997
1996
|
}
|
|
1998
1997
|
if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
1998
|
+
return getComment(node);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
function getComment(node) {
|
|
2002
|
+
var rawValue = getLeadingCommentBlock(node);
|
|
2003
|
+
if (rawValue !== undefined) {
|
|
2004
|
+
return dedentBlockStringValue("\n" + rawValue);
|
|
2003
2005
|
}
|
|
2004
2006
|
}
|
|
2005
2007
|
function getLeadingCommentBlock(node) {
|
|
@@ -4729,4 +4731,4 @@ function fixSchemaAst(schema, options) {
|
|
|
4729
4731
|
return schema;
|
|
4730
4732
|
}
|
|
4731
4733
|
|
|
4732
|
-
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, 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 };
|
|
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
package/index.js
CHANGED
|
@@ -1324,7 +1324,7 @@ function collectComment(node) {
|
|
|
1324
1324
|
}
|
|
1325
1325
|
}
|
|
1326
1326
|
function pushComment(node, entity, field, argument) {
|
|
1327
|
-
const comment =
|
|
1327
|
+
const comment = getComment(node);
|
|
1328
1328
|
if (typeof comment !== 'string' || comment.length === 0) {
|
|
1329
1329
|
return;
|
|
1330
1330
|
}
|
|
@@ -1460,7 +1460,12 @@ const printDocASTReducer = {
|
|
|
1460
1460
|
IntValue: { leave: ({ value }) => value },
|
|
1461
1461
|
FloatValue: { leave: ({ value }) => value },
|
|
1462
1462
|
StringValue: {
|
|
1463
|
-
leave: ({ value, block: isBlockString }) =>
|
|
1463
|
+
leave: ({ value, block: isBlockString }) => {
|
|
1464
|
+
if (isBlockString) {
|
|
1465
|
+
return printBlockString(value);
|
|
1466
|
+
}
|
|
1467
|
+
return JSON.stringify(value);
|
|
1468
|
+
},
|
|
1464
1469
|
},
|
|
1465
1470
|
BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },
|
|
1466
1471
|
NullValue: { leave: () => 'null' },
|
|
@@ -1478,21 +1483,19 @@ const printDocASTReducer = {
|
|
|
1478
1483
|
NonNullType: { leave: ({ type }) => type + '!' },
|
|
1479
1484
|
// Type System Definitions
|
|
1480
1485
|
SchemaDefinition: {
|
|
1481
|
-
leave: ({
|
|
1486
|
+
leave: ({ directives, operationTypes }) => join(['schema', join(directives, ' '), block(operationTypes)], ' '),
|
|
1482
1487
|
},
|
|
1483
1488
|
OperationTypeDefinition: {
|
|
1484
1489
|
leave: ({ operation, type }) => operation + ': ' + type,
|
|
1485
1490
|
},
|
|
1486
1491
|
ScalarTypeDefinition: {
|
|
1487
|
-
leave: ({
|
|
1492
|
+
leave: ({ name, directives }) => join(['scalar', name, join(directives, ' ')], ' '),
|
|
1488
1493
|
},
|
|
1489
1494
|
ObjectTypeDefinition: {
|
|
1490
|
-
leave: ({
|
|
1491
|
-
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)], ' '),
|
|
1492
1496
|
},
|
|
1493
1497
|
FieldDefinition: {
|
|
1494
|
-
leave: ({
|
|
1495
|
-
name +
|
|
1498
|
+
leave: ({ name, arguments: args, type, directives }) => name +
|
|
1496
1499
|
(hasMultilineItems(args)
|
|
1497
1500
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
1498
1501
|
: wrap('(', join(args, ', '), ')')) +
|
|
@@ -1501,27 +1504,25 @@ const printDocASTReducer = {
|
|
|
1501
1504
|
wrap(' ', join(directives, ' ')),
|
|
1502
1505
|
},
|
|
1503
1506
|
InputValueDefinition: {
|
|
1504
|
-
leave: ({
|
|
1507
|
+
leave: ({ name, type, defaultValue, directives }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
|
|
1505
1508
|
},
|
|
1506
1509
|
InterfaceTypeDefinition: {
|
|
1507
|
-
leave: ({
|
|
1508
|
-
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)], ' '),
|
|
1509
1511
|
},
|
|
1510
1512
|
UnionTypeDefinition: {
|
|
1511
|
-
leave: ({
|
|
1513
|
+
leave: ({ name, directives, types }) => join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
1512
1514
|
},
|
|
1513
1515
|
EnumTypeDefinition: {
|
|
1514
|
-
leave: ({
|
|
1516
|
+
leave: ({ name, directives, values }) => join(['enum', name, join(directives, ' '), block(values)], ' '),
|
|
1515
1517
|
},
|
|
1516
1518
|
EnumValueDefinition: {
|
|
1517
|
-
leave: ({
|
|
1519
|
+
leave: ({ name, directives }) => join([name, join(directives, ' ')], ' '),
|
|
1518
1520
|
},
|
|
1519
1521
|
InputObjectTypeDefinition: {
|
|
1520
|
-
leave: ({
|
|
1522
|
+
leave: ({ name, directives, fields }) => join(['input', name, join(directives, ' '), block(fields)], ' '),
|
|
1521
1523
|
},
|
|
1522
1524
|
DirectiveDefinition: {
|
|
1523
|
-
leave: ({
|
|
1524
|
-
'directive @' +
|
|
1525
|
+
leave: ({ name, arguments: args, repeatable, locations }) => 'directive @' +
|
|
1525
1526
|
name +
|
|
1526
1527
|
(hasMultilineItems(args)
|
|
1527
1528
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
@@ -1574,10 +1575,13 @@ function getDescription(node, options) {
|
|
|
1574
1575
|
return node.description.value;
|
|
1575
1576
|
}
|
|
1576
1577
|
if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1578
|
+
return getComment(node);
|
|
1579
|
+
}
|
|
1580
|
+
}
|
|
1581
|
+
function getComment(node) {
|
|
1582
|
+
const rawValue = getLeadingCommentBlock(node);
|
|
1583
|
+
if (rawValue !== undefined) {
|
|
1584
|
+
return dedentBlockStringValue(`\n${rawValue}`);
|
|
1581
1585
|
}
|
|
1582
1586
|
}
|
|
1583
1587
|
function getLeadingCommentBlock(node) {
|
|
@@ -4211,6 +4215,7 @@ exports.forEachField = forEachField;
|
|
|
4211
4215
|
exports.getArgumentValues = getArgumentValues;
|
|
4212
4216
|
exports.getBlockStringIndentation = getBlockStringIndentation;
|
|
4213
4217
|
exports.getBuiltInForStub = getBuiltInForStub;
|
|
4218
|
+
exports.getComment = getComment;
|
|
4214
4219
|
exports.getDefinedRootType = getDefinedRootType;
|
|
4215
4220
|
exports.getDeprecatableDirectiveNodes = getDeprecatableDirectiveNodes;
|
|
4216
4221
|
exports.getDescription = getDescription;
|
package/index.mjs
CHANGED
|
@@ -1320,7 +1320,7 @@ function collectComment(node) {
|
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
1322
|
function pushComment(node, entity, field, argument) {
|
|
1323
|
-
const comment =
|
|
1323
|
+
const comment = getComment(node);
|
|
1324
1324
|
if (typeof comment !== 'string' || comment.length === 0) {
|
|
1325
1325
|
return;
|
|
1326
1326
|
}
|
|
@@ -1456,7 +1456,12 @@ const printDocASTReducer = {
|
|
|
1456
1456
|
IntValue: { leave: ({ value }) => value },
|
|
1457
1457
|
FloatValue: { leave: ({ value }) => value },
|
|
1458
1458
|
StringValue: {
|
|
1459
|
-
leave: ({ value, block: isBlockString }) =>
|
|
1459
|
+
leave: ({ value, block: isBlockString }) => {
|
|
1460
|
+
if (isBlockString) {
|
|
1461
|
+
return printBlockString(value);
|
|
1462
|
+
}
|
|
1463
|
+
return JSON.stringify(value);
|
|
1464
|
+
},
|
|
1460
1465
|
},
|
|
1461
1466
|
BooleanValue: { leave: ({ value }) => (value ? 'true' : 'false') },
|
|
1462
1467
|
NullValue: { leave: () => 'null' },
|
|
@@ -1474,21 +1479,19 @@ const printDocASTReducer = {
|
|
|
1474
1479
|
NonNullType: { leave: ({ type }) => type + '!' },
|
|
1475
1480
|
// Type System Definitions
|
|
1476
1481
|
SchemaDefinition: {
|
|
1477
|
-
leave: ({
|
|
1482
|
+
leave: ({ directives, operationTypes }) => join(['schema', join(directives, ' '), block(operationTypes)], ' '),
|
|
1478
1483
|
},
|
|
1479
1484
|
OperationTypeDefinition: {
|
|
1480
1485
|
leave: ({ operation, type }) => operation + ': ' + type,
|
|
1481
1486
|
},
|
|
1482
1487
|
ScalarTypeDefinition: {
|
|
1483
|
-
leave: ({
|
|
1488
|
+
leave: ({ name, directives }) => join(['scalar', name, join(directives, ' ')], ' '),
|
|
1484
1489
|
},
|
|
1485
1490
|
ObjectTypeDefinition: {
|
|
1486
|
-
leave: ({
|
|
1487
|
-
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)], ' '),
|
|
1488
1492
|
},
|
|
1489
1493
|
FieldDefinition: {
|
|
1490
|
-
leave: ({
|
|
1491
|
-
name +
|
|
1494
|
+
leave: ({ name, arguments: args, type, directives }) => name +
|
|
1492
1495
|
(hasMultilineItems(args)
|
|
1493
1496
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
1494
1497
|
: wrap('(', join(args, ', '), ')')) +
|
|
@@ -1497,27 +1500,25 @@ const printDocASTReducer = {
|
|
|
1497
1500
|
wrap(' ', join(directives, ' ')),
|
|
1498
1501
|
},
|
|
1499
1502
|
InputValueDefinition: {
|
|
1500
|
-
leave: ({
|
|
1503
|
+
leave: ({ name, type, defaultValue, directives }) => join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' '),
|
|
1501
1504
|
},
|
|
1502
1505
|
InterfaceTypeDefinition: {
|
|
1503
|
-
leave: ({
|
|
1504
|
-
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)], ' '),
|
|
1505
1507
|
},
|
|
1506
1508
|
UnionTypeDefinition: {
|
|
1507
|
-
leave: ({
|
|
1509
|
+
leave: ({ name, directives, types }) => join(['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], ' '),
|
|
1508
1510
|
},
|
|
1509
1511
|
EnumTypeDefinition: {
|
|
1510
|
-
leave: ({
|
|
1512
|
+
leave: ({ name, directives, values }) => join(['enum', name, join(directives, ' '), block(values)], ' '),
|
|
1511
1513
|
},
|
|
1512
1514
|
EnumValueDefinition: {
|
|
1513
|
-
leave: ({
|
|
1515
|
+
leave: ({ name, directives }) => join([name, join(directives, ' ')], ' '),
|
|
1514
1516
|
},
|
|
1515
1517
|
InputObjectTypeDefinition: {
|
|
1516
|
-
leave: ({
|
|
1518
|
+
leave: ({ name, directives, fields }) => join(['input', name, join(directives, ' '), block(fields)], ' '),
|
|
1517
1519
|
},
|
|
1518
1520
|
DirectiveDefinition: {
|
|
1519
|
-
leave: ({
|
|
1520
|
-
'directive @' +
|
|
1521
|
+
leave: ({ name, arguments: args, repeatable, locations }) => 'directive @' +
|
|
1521
1522
|
name +
|
|
1522
1523
|
(hasMultilineItems(args)
|
|
1523
1524
|
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
@@ -1570,10 +1571,13 @@ function getDescription(node, options) {
|
|
|
1570
1571
|
return node.description.value;
|
|
1571
1572
|
}
|
|
1572
1573
|
if (options === null || options === void 0 ? void 0 : options.commentDescriptions) {
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1574
|
+
return getComment(node);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
function getComment(node) {
|
|
1578
|
+
const rawValue = getLeadingCommentBlock(node);
|
|
1579
|
+
if (rawValue !== undefined) {
|
|
1580
|
+
return dedentBlockStringValue(`\n${rawValue}`);
|
|
1577
1581
|
}
|
|
1578
1582
|
}
|
|
1579
1583
|
function getLeadingCommentBlock(node) {
|
|
@@ -4172,4 +4176,4 @@ function fixSchemaAst(schema, options) {
|
|
|
4172
4176
|
return schema;
|
|
4173
4177
|
}
|
|
4174
4178
|
|
|
4175
|
-
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, 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 };
|
|
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 };
|