graphql 16.14.2 → 16.15.0
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/error/GraphQLError.d.ts +5 -1
- package/error/GraphQLError.js +12 -7
- package/error/GraphQLError.mjs +13 -6
- package/error/locatedError.d.ts +6 -4
- package/error/locatedError.js +6 -4
- package/error/locatedError.mjs +6 -4
- package/execution/collectFields.d.ts +1 -0
- package/execution/collectFields.js +9 -0
- package/execution/collectFields.mjs +9 -0
- package/execution/execute.d.ts +9 -10
- package/execution/execute.js +44 -29
- package/execution/execute.mjs +44 -29
- package/execution/mapAsyncIterator.js +12 -11
- package/execution/mapAsyncIterator.mjs +12 -11
- package/execution/subscribe.d.ts +5 -2
- package/execution/subscribe.js +5 -2
- package/execution/subscribe.mjs +5 -2
- package/execution/values.d.ts +43 -21
- package/execution/values.js +52 -24
- package/execution/values.mjs +51 -23
- package/graphql.d.ts +8 -14
- package/graphql.js +16 -15
- package/graphql.mjs +11 -15
- package/jsutils/SetMap.d.ts +14 -0
- package/jsutils/SetMap.js +48 -0
- package/jsutils/SetMap.mjs +39 -0
- package/jsutils/isIterableObject.d.ts +2 -0
- package/jsutils/isIterableObject.js +2 -0
- package/jsutils/isIterableObject.mjs +2 -0
- package/jsutils/keyMap.d.ts +2 -0
- package/jsutils/keyMap.js +2 -0
- package/jsutils/keyMap.mjs +2 -0
- package/jsutils/keyValMap.d.ts +3 -3
- package/jsutils/keyValMap.js +3 -3
- package/jsutils/keyValMap.mjs +3 -3
- package/language/ast.d.ts +2 -6
- package/language/ast.js +2 -6
- package/language/ast.mjs +2 -6
- package/language/lexer.d.ts +6 -0
- package/language/lexer.js +22 -0
- package/language/lexer.mjs +22 -0
- package/language/location.d.ts +8 -3
- package/language/location.js +57 -17
- package/language/location.mjs +56 -16
- package/language/parser.d.ts +27 -13
- package/language/parser.js +31 -9
- package/language/parser.mjs +31 -9
- package/language/predicates.d.ts +10 -3
- package/language/predicates.js +10 -3
- package/language/predicates.mjs +10 -3
- package/language/printLocation.d.ts +2 -6
- package/language/printLocation.js +2 -6
- package/language/printLocation.mjs +2 -6
- package/language/printer.d.ts +22 -3
- package/language/printer.js +394 -308
- package/language/printer.mjs +394 -308
- package/language/reducer.d.ts +32 -0
- package/language/reducer.js +95 -0
- package/language/reducer.mjs +86 -0
- package/language/source.d.ts +4 -5
- package/language/source.js +4 -5
- package/language/source.mjs +4 -5
- package/language/visitor.d.ts +16 -10
- package/language/visitor.js +15 -7
- package/language/visitor.mjs +15 -7
- package/package.json +1 -4
- package/type/definition.d.ts +170 -102
- package/type/definition.js +169 -96
- package/type/definition.mjs +168 -95
- package/type/directives.d.ts +12 -6
- package/type/directives.js +12 -6
- package/type/directives.mjs +12 -6
- package/type/scalars.js +8 -11
- package/type/scalars.mjs +1 -1
- package/type/schema.d.ts +36 -11
- package/type/schema.js +35 -10
- package/type/schema.mjs +35 -10
- package/type/validate.d.ts +1 -3
- package/type/validate.js +1 -3
- package/type/validate.mjs +1 -3
- package/utilities/TypeInfo.d.ts +15 -11
- package/utilities/TypeInfo.js +15 -11
- package/utilities/TypeInfo.mjs +15 -11
- package/utilities/assertValidName.d.ts +1 -1
- package/utilities/assertValidName.js +1 -1
- package/utilities/assertValidName.mjs +1 -1
- package/utilities/astFromValue.d.ts +3 -1
- package/utilities/astFromValue.js +3 -1
- package/utilities/astFromValue.mjs +3 -1
- package/utilities/buildASTSchema.d.ts +8 -8
- package/utilities/buildASTSchema.js +9 -20
- package/utilities/buildASTSchema.mjs +9 -20
- package/utilities/buildClientSchema.d.ts +6 -2
- package/utilities/buildClientSchema.js +6 -2
- package/utilities/buildClientSchema.mjs +6 -2
- package/utilities/coerceInputValue.d.ts +9 -3
- package/utilities/coerceInputValue.js +60 -13
- package/utilities/coerceInputValue.mjs +58 -13
- package/utilities/concatAST.d.ts +4 -1
- package/utilities/concatAST.js +4 -1
- package/utilities/concatAST.mjs +4 -1
- package/utilities/extendSchema.d.ts +7 -4
- package/utilities/extendSchema.js +7 -4
- package/utilities/extendSchema.mjs +7 -4
- package/utilities/findBreakingChanges.d.ts +2 -2
- package/utilities/findBreakingChanges.js +2 -2
- package/utilities/findBreakingChanges.mjs +2 -2
- package/utilities/getIntrospectionQuery.d.ts +9 -9
- package/utilities/getIntrospectionQuery.js +8 -8
- package/utilities/getIntrospectionQuery.mjs +8 -8
- package/utilities/getOperationAST.d.ts +2 -2
- package/utilities/getOperationAST.js +2 -2
- package/utilities/getOperationAST.mjs +2 -2
- package/utilities/getOperationRootType.d.ts +3 -1
- package/utilities/getOperationRootType.js +3 -1
- package/utilities/getOperationRootType.mjs +3 -1
- package/utilities/introspectionFromSchema.d.ts +12 -4
- package/utilities/introspectionFromSchema.js +12 -4
- package/utilities/introspectionFromSchema.mjs +12 -4
- package/utilities/lexicographicSortSchema.d.ts +17 -13
- package/utilities/lexicographicSortSchema.js +17 -13
- package/utilities/lexicographicSortSchema.mjs +17 -13
- package/utilities/printSchema.d.ts +7 -4
- package/utilities/printSchema.js +7 -4
- package/utilities/printSchema.mjs +7 -4
- package/utilities/resolveSchemaCoordinate.d.ts +9 -8
- package/utilities/resolveSchemaCoordinate.js +9 -8
- package/utilities/resolveSchemaCoordinate.mjs +9 -8
- package/utilities/separateOperations.d.ts +2 -2
- package/utilities/separateOperations.js +2 -2
- package/utilities/separateOperations.mjs +2 -2
- package/utilities/stripIgnoredCharacters.d.ts +19 -5
- package/utilities/stripIgnoredCharacters.js +19 -5
- package/utilities/stripIgnoredCharacters.mjs +19 -5
- package/utilities/typeComparators.d.ts +1 -5
- package/utilities/typeComparators.js +1 -5
- package/utilities/typeComparators.mjs +1 -5
- package/utilities/valueFromAST.js +4 -4
- package/utilities/valueFromAST.mjs +4 -4
- package/utilities/valueFromASTUntyped.d.ts +1 -3
- package/utilities/valueFromASTUntyped.js +1 -3
- package/utilities/valueFromASTUntyped.mjs +1 -3
- package/validation/ValidationContext.d.ts +22 -3
- package/validation/ValidationContext.js +84 -27
- package/validation/ValidationContext.mjs +82 -27
- package/validation/rules/ExecutableDefinitionsRule.d.ts +6 -4
- package/validation/rules/ExecutableDefinitionsRule.js +6 -4
- package/validation/rules/ExecutableDefinitionsRule.mjs +6 -4
- package/validation/rules/FieldsOnCorrectTypeRule.d.ts +4 -4
- package/validation/rules/FieldsOnCorrectTypeRule.js +10 -6
- package/validation/rules/FieldsOnCorrectTypeRule.mjs +12 -6
- package/validation/rules/FragmentsOnCompositeTypesRule.d.ts +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.js +6 -4
- package/validation/rules/FragmentsOnCompositeTypesRule.mjs +6 -4
- package/validation/rules/KnownArgumentNamesRule.d.ts +4 -4
- package/validation/rules/KnownArgumentNamesRule.js +26 -17
- package/validation/rules/KnownArgumentNamesRule.mjs +21 -11
- package/validation/rules/KnownDirectivesRule.d.ts +1 -3
- package/validation/rules/KnownDirectivesRule.js +1 -3
- package/validation/rules/KnownDirectivesRule.mjs +1 -3
- package/validation/rules/KnownFragmentNamesRule.d.ts +4 -4
- package/validation/rules/KnownFragmentNamesRule.js +4 -4
- package/validation/rules/KnownFragmentNamesRule.mjs +4 -4
- package/validation/rules/KnownTypeNamesRule.d.ts +1 -3
- package/validation/rules/KnownTypeNamesRule.js +7 -7
- package/validation/rules/KnownTypeNamesRule.mjs +7 -7
- package/validation/rules/LoneAnonymousOperationRule.d.ts +6 -4
- package/validation/rules/LoneAnonymousOperationRule.js +6 -4
- package/validation/rules/LoneAnonymousOperationRule.mjs +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.d.ts +6 -4
- package/validation/rules/MaxIntrospectionDepthRule.js +44 -19
- package/validation/rules/MaxIntrospectionDepthRule.mjs +44 -19
- package/validation/rules/NoFragmentCyclesRule.d.ts +1 -3
- package/validation/rules/NoFragmentCyclesRule.js +1 -3
- package/validation/rules/NoFragmentCyclesRule.mjs +1 -3
- package/validation/rules/NoUndefinedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUndefinedVariablesRule.js +4 -4
- package/validation/rules/NoUndefinedVariablesRule.mjs +4 -4
- package/validation/rules/NoUnusedFragmentsRule.d.ts +4 -4
- package/validation/rules/NoUnusedFragmentsRule.js +10 -14
- package/validation/rules/NoUnusedFragmentsRule.mjs +10 -14
- package/validation/rules/NoUnusedVariablesRule.d.ts +4 -4
- package/validation/rules/NoUnusedVariablesRule.js +4 -4
- package/validation/rules/NoUnusedVariablesRule.mjs +4 -4
- package/validation/rules/OverlappingFieldsCanBeMergedRule.d.ts +8 -6
- package/validation/rules/OverlappingFieldsCanBeMergedRule.js +552 -354
- package/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +545 -352
- package/validation/rules/PossibleFragmentSpreadsRule.d.ts +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.js +6 -4
- package/validation/rules/PossibleFragmentSpreadsRule.mjs +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.d.ts +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.js +6 -4
- package/validation/rules/ProvidedRequiredArgumentsRule.mjs +6 -4
- package/validation/rules/ScalarLeafsRule.d.ts +1 -3
- package/validation/rules/ScalarLeafsRule.js +1 -3
- package/validation/rules/ScalarLeafsRule.mjs +1 -3
- package/validation/rules/SingleFieldSubscriptionsRule.d.ts +6 -4
- package/validation/rules/SingleFieldSubscriptionsRule.js +50 -9
- package/validation/rules/SingleFieldSubscriptionsRule.mjs +50 -9
- package/validation/rules/UniqueArgumentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueArgumentNamesRule.js +4 -4
- package/validation/rules/UniqueArgumentNamesRule.mjs +4 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.d.ts +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.js +6 -4
- package/validation/rules/UniqueDirectivesPerLocationRule.mjs +6 -4
- package/validation/rules/UniqueFragmentNamesRule.d.ts +4 -4
- package/validation/rules/UniqueFragmentNamesRule.js +4 -4
- package/validation/rules/UniqueFragmentNamesRule.mjs +4 -4
- package/validation/rules/UniqueInputFieldNamesRule.d.ts +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.js +6 -4
- package/validation/rules/UniqueInputFieldNamesRule.mjs +6 -4
- package/validation/rules/UniqueOperationNamesRule.d.ts +4 -4
- package/validation/rules/UniqueOperationNamesRule.js +4 -4
- package/validation/rules/UniqueOperationNamesRule.mjs +4 -4
- package/validation/rules/UniqueVariableNamesRule.d.ts +4 -4
- package/validation/rules/UniqueVariableNamesRule.js +4 -4
- package/validation/rules/UniqueVariableNamesRule.mjs +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.d.ts +4 -4
- package/validation/rules/ValuesOfCorrectTypeRule.js +29 -23
- package/validation/rules/ValuesOfCorrectTypeRule.mjs +24 -14
- package/validation/rules/VariablesAreInputTypesRule.d.ts +6 -4
- package/validation/rules/VariablesAreInputTypesRule.js +6 -4
- package/validation/rules/VariablesAreInputTypesRule.mjs +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.d.ts +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.js +6 -4
- package/validation/rules/VariablesInAllowedPositionRule.mjs +6 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.d.ts +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.js +4 -4
- package/validation/rules/custom/NoDeprecatedCustomRule.mjs +4 -4
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.d.ts +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.js +7 -5
- package/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs +7 -5
- package/validation/validate.d.ts +2 -0
- package/validation/validate.js +14 -2
- package/validation/validate.mjs +13 -2
- package/validation/validationAbortedError.d.ts +3 -0
- package/validation/validationAbortedError.js +14 -0
- package/validation/validationAbortedError.mjs +4 -0
- package/version.js +3 -3
- package/version.mjs +3 -3
package/language/printer.js
CHANGED
|
@@ -4,188 +4,254 @@ Object.defineProperty(exports, '__esModule', {
|
|
|
4
4
|
value: true,
|
|
5
5
|
});
|
|
6
6
|
exports.print = print;
|
|
7
|
+
exports.printForError = printForError;
|
|
7
8
|
|
|
8
9
|
var _blockString = require('./blockString.js');
|
|
9
10
|
|
|
10
11
|
var _printString = require('./printString.js');
|
|
11
12
|
|
|
12
|
-
var
|
|
13
|
+
var _reducer = require('./reducer.js');
|
|
13
14
|
|
|
14
15
|
/** @category Printing */
|
|
15
16
|
|
|
16
|
-
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
function print(ast) {
|
|
32
|
-
return (0, _visitor.visit)(ast, printDocASTReducer);
|
|
17
|
+
/** @internal */
|
|
18
|
+
function print(ast, options) {
|
|
19
|
+
var _options$maxIndentDep;
|
|
20
|
+
|
|
21
|
+
return render(
|
|
22
|
+
(0, _reducer.reduce)(ast, printDocASTReducer),
|
|
23
|
+
(_options$maxIndentDep =
|
|
24
|
+
options === null || options === void 0
|
|
25
|
+
? void 0
|
|
26
|
+
: options.maxIndentDepth) !== null && _options$maxIndentDep !== void 0
|
|
27
|
+
? _options$maxIndentDep
|
|
28
|
+
: Infinity,
|
|
29
|
+
);
|
|
33
30
|
}
|
|
31
|
+
/** @internal */
|
|
32
|
+
|
|
33
|
+
function printForError(ast) {
|
|
34
|
+
return print(ast, {
|
|
35
|
+
maxIndentDepth: 100,
|
|
36
|
+
});
|
|
37
|
+
} // The wrapping limit applies to total string length, including newlines.
|
|
34
38
|
|
|
35
39
|
const MAX_LINE_LENGTH = 80;
|
|
36
|
-
const printDocASTReducer = {
|
|
37
|
-
Name: {
|
|
38
|
-
leave: (node) => node.value,
|
|
39
|
-
},
|
|
40
|
-
Variable: {
|
|
41
|
-
leave: (node) => '$' + node.name,
|
|
42
|
-
},
|
|
43
|
-
// Document
|
|
44
|
-
Document: {
|
|
45
|
-
leave: (node) => join(node.definitions, '\n\n'),
|
|
46
|
-
},
|
|
47
|
-
OperationDefinition: {
|
|
48
|
-
leave(node) {
|
|
49
|
-
const varDefs = hasMultilineItems(node.variableDefinitions)
|
|
50
|
-
? wrap('(\n', join(node.variableDefinitions, '\n'), '\n)')
|
|
51
|
-
: wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
52
|
-
const prefix =
|
|
53
|
-
wrap('', node.description, '\n') +
|
|
54
|
-
join(
|
|
55
|
-
[
|
|
56
|
-
node.operation,
|
|
57
|
-
join([node.name, varDefs]),
|
|
58
|
-
join(node.directives, ' '),
|
|
59
|
-
],
|
|
60
|
-
' ',
|
|
61
|
-
); // Anonymous queries with no directives or variable definitions can use
|
|
62
|
-
// the query short form.
|
|
63
|
-
|
|
64
|
-
return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet;
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
VariableDefinition: {
|
|
68
|
-
leave: ({ variable, type, defaultValue, directives, description }) =>
|
|
69
|
-
wrap('', description, '\n') +
|
|
70
|
-
variable +
|
|
71
|
-
': ' +
|
|
72
|
-
type +
|
|
73
|
-
wrap(' = ', defaultValue) +
|
|
74
|
-
wrap(' ', join(directives, ' ')),
|
|
75
|
-
},
|
|
76
|
-
SelectionSet: {
|
|
77
|
-
leave: ({ selections }) => block(selections),
|
|
78
|
-
},
|
|
79
|
-
Field: {
|
|
80
|
-
leave({ alias, name, arguments: args, directives, selectionSet }) {
|
|
81
|
-
const prefix = wrap('', alias, ': ') + name;
|
|
82
|
-
let argsLine = prefix + wrap('(', join(args, ', '), ')');
|
|
83
40
|
|
|
84
|
-
|
|
85
|
-
|
|
41
|
+
class PrintBuffer {
|
|
42
|
+
next = undefined;
|
|
43
|
+
tail = this;
|
|
44
|
+
indentBefore = false;
|
|
45
|
+
dedentAfter = false;
|
|
46
|
+
|
|
47
|
+
constructor(value = '', isBlockString = false) {
|
|
48
|
+
this.length = value.length;
|
|
49
|
+
this.lines = value.includes('\n') ? value.split('\n') : value;
|
|
50
|
+
this.newlines = typeof this.lines === 'string' ? 0 : this.lines.length - 1;
|
|
51
|
+
this.isBlockString = isBlockString;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
append(result) {
|
|
55
|
+
if (result.length === 0) {
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const next = typeof result === 'string' ? new PrintBuffer(result) : result;
|
|
60
|
+
this.tail.next = next;
|
|
61
|
+
this.tail = next.tail;
|
|
62
|
+
this.length += next.length;
|
|
63
|
+
this.newlines += next.newlines;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
indent() {
|
|
68
|
+
if (this.length === 0) {
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
this.indentBefore = true;
|
|
73
|
+
this.tail.dedentAfter = true;
|
|
74
|
+
this.length += 2 * (this.newlines + 1);
|
|
75
|
+
return this;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const EMPTY = new PrintBuffer();
|
|
80
|
+
|
|
81
|
+
function render(buffer, maxDepth) {
|
|
82
|
+
let output = '';
|
|
83
|
+
let text = '';
|
|
84
|
+
let depth = 0;
|
|
85
|
+
let indentation = '';
|
|
86
|
+
let part = buffer;
|
|
87
|
+
|
|
88
|
+
while (part !== undefined) {
|
|
89
|
+
const lines = part.lines;
|
|
90
|
+
|
|
91
|
+
if (part.indentBefore) {
|
|
92
|
+
if (depth < maxDepth) {
|
|
93
|
+
indentation += ' ';
|
|
94
|
+
text += ' ';
|
|
86
95
|
}
|
|
87
96
|
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
depth++;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (typeof lines === 'string') {
|
|
101
|
+
text += lines;
|
|
102
|
+
} else {
|
|
103
|
+
text += lines[0];
|
|
104
|
+
const newline =
|
|
105
|
+
!part.isBlockString && depth >= maxDepth ? ' ' : '\n' + indentation;
|
|
106
|
+
|
|
107
|
+
for (let i = 1; i < lines.length; i++) {
|
|
108
|
+
output += text;
|
|
109
|
+
text = newline + lines[i];
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (part.dedentAfter) {
|
|
114
|
+
depth--;
|
|
115
|
+
indentation = indentation.slice(0, depth * 2);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
part = part.next;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return output + text;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const printDocASTReducer = {
|
|
125
|
+
Name: (node) => new PrintBuffer(node.value),
|
|
126
|
+
Variable: (node) => join(['$', node.name]),
|
|
127
|
+
// Document
|
|
128
|
+
Document: (node) => join(node.definitions, '\n\n'),
|
|
129
|
+
|
|
130
|
+
OperationDefinition(node) {
|
|
131
|
+
const varDefs = hasMultilineItems(node.variableDefinitions)
|
|
132
|
+
? wrap('(\n', join(node.variableDefinitions, '\n'), '\n)')
|
|
133
|
+
: wrap('(', join(node.variableDefinitions, ', '), ')');
|
|
134
|
+
const prefix = join([
|
|
135
|
+
wrap('', node.description, '\n'),
|
|
101
136
|
join(
|
|
102
137
|
[
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
join(directives, ' '),
|
|
106
|
-
selectionSet,
|
|
138
|
+
node.operation,
|
|
139
|
+
join([node.name, varDefs]),
|
|
140
|
+
join(node.directives, ' '),
|
|
107
141
|
],
|
|
108
142
|
' ',
|
|
109
143
|
),
|
|
144
|
+
]); // Anonymous queries with no directives or variable definitions can use
|
|
145
|
+
// the query short form.
|
|
146
|
+
|
|
147
|
+
return join([
|
|
148
|
+
node.operation === 'query' && prefix.length === node.operation.length
|
|
149
|
+
? ''
|
|
150
|
+
: join([prefix, ' ']),
|
|
151
|
+
node.selectionSet,
|
|
152
|
+
]);
|
|
153
|
+
},
|
|
154
|
+
|
|
155
|
+
VariableDefinition: ({
|
|
156
|
+
variable,
|
|
157
|
+
type,
|
|
158
|
+
defaultValue,
|
|
159
|
+
directives,
|
|
160
|
+
description,
|
|
161
|
+
}) =>
|
|
162
|
+
join([
|
|
163
|
+
wrap('', description, '\n'),
|
|
164
|
+
variable,
|
|
165
|
+
': ',
|
|
166
|
+
type,
|
|
167
|
+
wrap(' = ', defaultValue),
|
|
168
|
+
wrap(' ', join(directives, ' ')),
|
|
169
|
+
]),
|
|
170
|
+
SelectionSet: ({ selections }) => block(selections),
|
|
171
|
+
|
|
172
|
+
Field({ alias, name, arguments: args, directives, selectionSet }) {
|
|
173
|
+
const prefix = join([wrap('', alias, ': '), name], '');
|
|
174
|
+
return join([
|
|
175
|
+
wrappedLineAndArgs(prefix, args),
|
|
176
|
+
wrap(' ', join(directives, ' ')),
|
|
177
|
+
wrap(' ', selectionSet),
|
|
178
|
+
]);
|
|
110
179
|
},
|
|
111
|
-
|
|
112
|
-
|
|
180
|
+
|
|
181
|
+
Argument: ({ name, value }) => join([name, ': ', value]),
|
|
182
|
+
// Fragments
|
|
183
|
+
FragmentSpread: ({ name, directives }) =>
|
|
184
|
+
join(['...', name, wrap(' ', join(directives, ' '))]),
|
|
185
|
+
InlineFragment: ({ typeCondition, directives, selectionSet }) =>
|
|
186
|
+
join(
|
|
187
|
+
['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet],
|
|
188
|
+
' ',
|
|
189
|
+
),
|
|
190
|
+
FragmentDefinition: ({
|
|
191
|
+
name,
|
|
192
|
+
typeCondition,
|
|
193
|
+
variableDefinitions,
|
|
194
|
+
directives,
|
|
195
|
+
selectionSet,
|
|
196
|
+
description,
|
|
197
|
+
}) =>
|
|
198
|
+
join([
|
|
199
|
+
wrap('', description, '\n'), // Note: fragment variable definitions are experimental and may be changed
|
|
200
|
+
// or removed in the future.
|
|
201
|
+
'fragment ',
|
|
113
202
|
name,
|
|
203
|
+
wrap('(', join(variableDefinitions, ', '), ')'),
|
|
204
|
+
' on ',
|
|
114
205
|
typeCondition,
|
|
115
|
-
|
|
116
|
-
directives,
|
|
206
|
+
' ',
|
|
207
|
+
wrap('', join(directives, ' '), ' '),
|
|
117
208
|
selectionSet,
|
|
118
|
-
|
|
119
|
-
}) =>
|
|
120
|
-
wrap('', description, '\n') + // Note: fragment variable definitions are experimental and may be changed
|
|
121
|
-
// or removed in the future.
|
|
122
|
-
`fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` +
|
|
123
|
-
`on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` +
|
|
124
|
-
selectionSet,
|
|
125
|
-
},
|
|
209
|
+
]),
|
|
126
210
|
// Value
|
|
127
|
-
IntValue: {
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
},
|
|
133
|
-
StringValue: {
|
|
134
|
-
leave: ({ value, block: isBlockString }) =>
|
|
135
|
-
isBlockString
|
|
211
|
+
IntValue: ({ value }) => new PrintBuffer(value),
|
|
212
|
+
FloatValue: ({ value }) => new PrintBuffer(value),
|
|
213
|
+
StringValue: ({ value, block: isBlockString }) =>
|
|
214
|
+
new PrintBuffer(
|
|
215
|
+
isBlockString === true
|
|
136
216
|
? (0, _blockString.printBlockString)(value)
|
|
137
217
|
: (0, _printString.printString)(value),
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
},
|
|
145
|
-
|
|
146
|
-
leave: ({ value }) => value,
|
|
147
|
-
},
|
|
148
|
-
ListValue: {
|
|
149
|
-
leave: ({ values }) => '[' + join(values, ', ') + ']',
|
|
150
|
-
},
|
|
151
|
-
ObjectValue: {
|
|
152
|
-
leave: ({ fields }) => '{' + join(fields, ', ') + '}',
|
|
153
|
-
},
|
|
154
|
-
ObjectField: {
|
|
155
|
-
leave: ({ name, value }) => name + ': ' + value,
|
|
156
|
-
},
|
|
218
|
+
isBlockString === true,
|
|
219
|
+
),
|
|
220
|
+
BooleanValue: ({ value }) => new PrintBuffer(value ? 'true' : 'false'),
|
|
221
|
+
NullValue: () => new PrintBuffer('null'),
|
|
222
|
+
EnumValue: ({ value }) => new PrintBuffer(value),
|
|
223
|
+
ListValue: ({ values }) => join(['[', join(values, ', '), ']']),
|
|
224
|
+
ObjectValue: ({ fields }) => join(['{', join(fields, ', '), '}']),
|
|
225
|
+
ObjectField: ({ name, value }) => join([name, ': ', value]),
|
|
157
226
|
// Directive
|
|
158
|
-
Directive: {
|
|
159
|
-
|
|
160
|
-
'@' + name + wrap('(', join(args, ', '), ')'),
|
|
161
|
-
},
|
|
227
|
+
Directive: ({ name, arguments: args }) =>
|
|
228
|
+
join(['@', name, wrap('(', join(args, ', '), ')')]),
|
|
162
229
|
// Type
|
|
163
|
-
NamedType: {
|
|
164
|
-
|
|
165
|
-
},
|
|
166
|
-
ListType: {
|
|
167
|
-
leave: ({ type }) => '[' + type + ']',
|
|
168
|
-
},
|
|
169
|
-
NonNullType: {
|
|
170
|
-
leave: ({ type }) => type + '!',
|
|
171
|
-
},
|
|
230
|
+
NamedType: ({ name }) => name,
|
|
231
|
+
ListType: ({ type }) => join(['[', type, ']']),
|
|
232
|
+
NonNullType: ({ type }) => join([type, '!']),
|
|
172
233
|
// Type System Definitions
|
|
173
|
-
SchemaDefinition: {
|
|
174
|
-
|
|
175
|
-
wrap('', description, '\n')
|
|
234
|
+
SchemaDefinition: ({ description, directives, operationTypes }) =>
|
|
235
|
+
join([
|
|
236
|
+
wrap('', description, '\n'),
|
|
176
237
|
join(['schema', join(directives, ' '), block(operationTypes)], ' '),
|
|
177
|
-
|
|
178
|
-
OperationTypeDefinition: {
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
wrap('', description, '\n') +
|
|
238
|
+
]),
|
|
239
|
+
OperationTypeDefinition: ({ operation, type }) =>
|
|
240
|
+
join([operation, ': ', type]),
|
|
241
|
+
ScalarTypeDefinition: ({ description, name, directives }) =>
|
|
242
|
+
join([
|
|
243
|
+
wrap('', description, '\n'),
|
|
184
244
|
join(['scalar', name, join(directives, ' ')], ' '),
|
|
185
|
-
|
|
186
|
-
ObjectTypeDefinition: {
|
|
187
|
-
|
|
188
|
-
|
|
245
|
+
]),
|
|
246
|
+
ObjectTypeDefinition: ({
|
|
247
|
+
description,
|
|
248
|
+
name,
|
|
249
|
+
interfaces,
|
|
250
|
+
directives,
|
|
251
|
+
fields,
|
|
252
|
+
}) =>
|
|
253
|
+
join([
|
|
254
|
+
wrap('', description, '\n'),
|
|
189
255
|
join(
|
|
190
256
|
[
|
|
191
257
|
'type',
|
|
@@ -196,29 +262,42 @@ const printDocASTReducer = {
|
|
|
196
262
|
],
|
|
197
263
|
' ',
|
|
198
264
|
),
|
|
199
|
-
|
|
200
|
-
FieldDefinition: {
|
|
201
|
-
|
|
202
|
-
wrap('', description, '\n')
|
|
203
|
-
name
|
|
204
|
-
|
|
205
|
-
? wrap('(\n',
|
|
206
|
-
: wrap('(', join(args, ', '), ')')
|
|
207
|
-
': '
|
|
208
|
-
type
|
|
265
|
+
]),
|
|
266
|
+
FieldDefinition: ({ description, name, arguments: args, type, directives }) =>
|
|
267
|
+
join([
|
|
268
|
+
wrap('', description, '\n'),
|
|
269
|
+
name,
|
|
270
|
+
hasMultilineItems(args)
|
|
271
|
+
? wrap('(\n', join(args, '\n').indent(), '\n)')
|
|
272
|
+
: wrap('(', join(args, ', '), ')'),
|
|
273
|
+
': ',
|
|
274
|
+
type,
|
|
209
275
|
wrap(' ', join(directives, ' ')),
|
|
210
|
-
|
|
211
|
-
InputValueDefinition: {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
276
|
+
]),
|
|
277
|
+
InputValueDefinition: ({
|
|
278
|
+
description,
|
|
279
|
+
name,
|
|
280
|
+
type,
|
|
281
|
+
defaultValue,
|
|
282
|
+
directives,
|
|
283
|
+
}) =>
|
|
284
|
+
join([
|
|
285
|
+
wrap('', description, '\n'),
|
|
286
|
+
name,
|
|
287
|
+
': ',
|
|
288
|
+
type,
|
|
289
|
+
wrap(' = ', defaultValue),
|
|
290
|
+
wrap(' ', join(directives, ' ')),
|
|
291
|
+
]),
|
|
292
|
+
InterfaceTypeDefinition: ({
|
|
293
|
+
description,
|
|
294
|
+
name,
|
|
295
|
+
interfaces,
|
|
296
|
+
directives,
|
|
297
|
+
fields,
|
|
298
|
+
}) =>
|
|
299
|
+
join([
|
|
300
|
+
wrap('', description, '\n'),
|
|
222
301
|
join(
|
|
223
302
|
[
|
|
224
303
|
'interface',
|
|
@@ -229,128 +308,101 @@ const printDocASTReducer = {
|
|
|
229
308
|
],
|
|
230
309
|
' ',
|
|
231
310
|
),
|
|
232
|
-
|
|
233
|
-
UnionTypeDefinition: {
|
|
234
|
-
|
|
235
|
-
wrap('', description, '\n')
|
|
311
|
+
]),
|
|
312
|
+
UnionTypeDefinition: ({ description, name, directives, types }) =>
|
|
313
|
+
join([
|
|
314
|
+
wrap('', description, '\n'),
|
|
236
315
|
join(
|
|
237
316
|
['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))],
|
|
238
317
|
' ',
|
|
239
318
|
),
|
|
240
|
-
|
|
241
|
-
EnumTypeDefinition: {
|
|
242
|
-
|
|
243
|
-
wrap('', description, '\n')
|
|
319
|
+
]),
|
|
320
|
+
EnumTypeDefinition: ({ description, name, directives, values }) =>
|
|
321
|
+
join([
|
|
322
|
+
wrap('', description, '\n'),
|
|
244
323
|
join(['enum', name, join(directives, ' '), block(values)], ' '),
|
|
245
|
-
|
|
246
|
-
EnumValueDefinition: {
|
|
247
|
-
|
|
248
|
-
wrap('', description, '\n')
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
324
|
+
]),
|
|
325
|
+
EnumValueDefinition: ({ description, name, directives }) =>
|
|
326
|
+
join([
|
|
327
|
+
wrap('', description, '\n'),
|
|
328
|
+
join([name, join(directives, ' ')], ' '),
|
|
329
|
+
]),
|
|
330
|
+
InputObjectTypeDefinition: ({ description, name, directives, fields }) =>
|
|
331
|
+
join([
|
|
332
|
+
wrap('', description, '\n'),
|
|
253
333
|
join(['input', name, join(directives, ' '), block(fields)], ' '),
|
|
254
|
-
|
|
255
|
-
DirectiveDefinition: {
|
|
256
|
-
|
|
257
|
-
|
|
334
|
+
]),
|
|
335
|
+
DirectiveDefinition: ({
|
|
336
|
+
description,
|
|
337
|
+
name,
|
|
338
|
+
arguments: args,
|
|
339
|
+
directives,
|
|
340
|
+
repeatable,
|
|
341
|
+
locations,
|
|
342
|
+
}) =>
|
|
343
|
+
join([
|
|
344
|
+
wrap('', description, '\n'),
|
|
345
|
+
'directive @',
|
|
258
346
|
name,
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
'directive @' +
|
|
266
|
-
name +
|
|
267
|
-
(hasMultilineItems(args)
|
|
268
|
-
? wrap('(\n', indent(join(args, '\n')), '\n)')
|
|
269
|
-
: wrap('(', join(args, ', '), ')')) +
|
|
270
|
-
wrap(' ', join(directives, ' ')) +
|
|
271
|
-
(repeatable ? ' repeatable' : '') +
|
|
272
|
-
' on ' +
|
|
347
|
+
hasMultilineItems(args)
|
|
348
|
+
? wrap('(\n', join(args, '\n').indent(), '\n)')
|
|
349
|
+
: wrap('(', join(args, ', '), ')'),
|
|
350
|
+
wrap(' ', join(directives, ' ')),
|
|
351
|
+
repeatable ? ' repeatable' : '',
|
|
352
|
+
' on ',
|
|
273
353
|
join(locations, ' | '),
|
|
274
|
-
|
|
275
|
-
SchemaExtension: {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
' ',
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
name,
|
|
318
|
-
join(directives, ' '),
|
|
319
|
-
wrap('= ', join(types, ' | ')),
|
|
320
|
-
],
|
|
321
|
-
' ',
|
|
322
|
-
),
|
|
323
|
-
},
|
|
324
|
-
EnumTypeExtension: {
|
|
325
|
-
leave: ({ name, directives, values }) =>
|
|
326
|
-
join(['extend enum', name, join(directives, ' '), block(values)], ' '),
|
|
327
|
-
},
|
|
328
|
-
InputObjectTypeExtension: {
|
|
329
|
-
leave: ({ name, directives, fields }) =>
|
|
330
|
-
join(['extend input', name, join(directives, ' '), block(fields)], ' '),
|
|
331
|
-
},
|
|
332
|
-
DirectiveExtension: {
|
|
333
|
-
leave: ({ name, directives }) =>
|
|
334
|
-
join(['extend directive @' + name, join(directives, ' ')], ' '),
|
|
335
|
-
},
|
|
354
|
+
]),
|
|
355
|
+
SchemaExtension: ({ directives, operationTypes }) =>
|
|
356
|
+
join(['extend schema', join(directives, ' '), block(operationTypes)], ' '),
|
|
357
|
+
ScalarTypeExtension: ({ name, directives }) =>
|
|
358
|
+
join(['extend scalar', name, join(directives, ' ')], ' '),
|
|
359
|
+
ObjectTypeExtension: ({ name, interfaces, directives, fields }) =>
|
|
360
|
+
join(
|
|
361
|
+
[
|
|
362
|
+
'extend type',
|
|
363
|
+
name,
|
|
364
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
365
|
+
join(directives, ' '),
|
|
366
|
+
block(fields),
|
|
367
|
+
],
|
|
368
|
+
' ',
|
|
369
|
+
),
|
|
370
|
+
InterfaceTypeExtension: ({ name, interfaces, directives, fields }) =>
|
|
371
|
+
join(
|
|
372
|
+
[
|
|
373
|
+
'extend interface',
|
|
374
|
+
name,
|
|
375
|
+
wrap('implements ', join(interfaces, ' & ')),
|
|
376
|
+
join(directives, ' '),
|
|
377
|
+
block(fields),
|
|
378
|
+
],
|
|
379
|
+
' ',
|
|
380
|
+
),
|
|
381
|
+
UnionTypeExtension: ({ name, directives, types }) =>
|
|
382
|
+
join(
|
|
383
|
+
[
|
|
384
|
+
'extend union',
|
|
385
|
+
name,
|
|
386
|
+
join(directives, ' '),
|
|
387
|
+
wrap('= ', join(types, ' | ')),
|
|
388
|
+
],
|
|
389
|
+
' ',
|
|
390
|
+
),
|
|
391
|
+
EnumTypeExtension: ({ name, directives, values }) =>
|
|
392
|
+
join(['extend enum', name, join(directives, ' '), block(values)], ' '),
|
|
393
|
+
InputObjectTypeExtension: ({ name, directives, fields }) =>
|
|
394
|
+
join(['extend input', name, join(directives, ' '), block(fields)], ' '),
|
|
395
|
+
DirectiveExtension: ({ name, directives }) =>
|
|
396
|
+
join([join(['extend directive @', name]), join(directives, ' ')], ' '),
|
|
336
397
|
// Schema Coordinates
|
|
337
|
-
TypeCoordinate: {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
},
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
join([name, wrap('.', fieldName), wrap('(', argumentName, ':)')]),
|
|
346
|
-
},
|
|
347
|
-
DirectiveCoordinate: {
|
|
348
|
-
leave: ({ name }) => join(['@', name]),
|
|
349
|
-
},
|
|
350
|
-
DirectiveArgumentCoordinate: {
|
|
351
|
-
leave: ({ name, argumentName }) =>
|
|
352
|
-
join(['@', name, wrap('(', argumentName, ':)')]),
|
|
353
|
-
},
|
|
398
|
+
TypeCoordinate: ({ name }) => name,
|
|
399
|
+
MemberCoordinate: ({ name, memberName }) =>
|
|
400
|
+
join([name, wrap('.', memberName)]),
|
|
401
|
+
ArgumentCoordinate: ({ name, fieldName, argumentName }) =>
|
|
402
|
+
join([name, wrap('.', fieldName), wrap('(', argumentName, ':)')]),
|
|
403
|
+
DirectiveCoordinate: ({ name }) => join(['@', name]),
|
|
404
|
+
DirectiveArgumentCoordinate: ({ name, argumentName }) =>
|
|
405
|
+
join(['@', name, wrap('(', argumentName, ':)')]),
|
|
354
406
|
};
|
|
355
407
|
/**
|
|
356
408
|
* Given maybeArray, print an empty string if it is null or empty, otherwise
|
|
@@ -360,15 +412,41 @@ const printDocASTReducer = {
|
|
|
360
412
|
*/
|
|
361
413
|
|
|
362
414
|
function join(maybeArray, separator = '') {
|
|
363
|
-
|
|
415
|
+
if (maybeArray == null || maybeArray.length === 0) {
|
|
416
|
+
return EMPTY;
|
|
417
|
+
}
|
|
364
418
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
419
|
+
let result = EMPTY;
|
|
420
|
+
|
|
421
|
+
for (const item of maybeArray) {
|
|
422
|
+
if (item === undefined || item.length === 0) {
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
if (result.length === 0) {
|
|
427
|
+
result = typeof item === 'string' ? new PrintBuffer(item) : item;
|
|
428
|
+
} else {
|
|
429
|
+
if (separator !== '') {
|
|
430
|
+
result.append(separator);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
result.append(item);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
return result;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function joinedLength(array, separator) {
|
|
441
|
+
let length = 0;
|
|
442
|
+
|
|
443
|
+
for (const item of array) {
|
|
444
|
+
if (item.length !== 0) {
|
|
445
|
+
length += (length === 0 ? 0 : separator.length) + item.length;
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
return length;
|
|
372
450
|
}
|
|
373
451
|
/**
|
|
374
452
|
* Given array, print each item on its own line, wrapped in an indented `{ }` block.
|
|
@@ -377,35 +455,43 @@ function join(maybeArray, separator = '') {
|
|
|
377
455
|
*/
|
|
378
456
|
|
|
379
457
|
function block(array) {
|
|
380
|
-
return wrap('{\n',
|
|
458
|
+
return wrap('{\n', join(array, '\n').indent(), '\n}');
|
|
381
459
|
}
|
|
382
460
|
/**
|
|
383
|
-
* If
|
|
461
|
+
* If maybeBuffer is not null or empty, then wrap with start and end, otherwise print an empty string.
|
|
384
462
|
*
|
|
385
463
|
* @internal
|
|
386
464
|
*/
|
|
387
465
|
|
|
388
|
-
function wrap(start,
|
|
389
|
-
return
|
|
390
|
-
? start
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
function indent(str) {
|
|
395
|
-
return wrap(' ', str.replace(/\n/g, '\n '));
|
|
466
|
+
function wrap(start, maybeBuffer, end = '') {
|
|
467
|
+
return maybeBuffer != null && maybeBuffer.length !== 0
|
|
468
|
+
? start === ''
|
|
469
|
+
? maybeBuffer.append(end)
|
|
470
|
+
: new PrintBuffer(start).append(maybeBuffer).append(end)
|
|
471
|
+
: EMPTY;
|
|
396
472
|
}
|
|
397
473
|
|
|
398
474
|
function hasMultilineItems(maybeArray) {
|
|
399
475
|
var _maybeArray$some;
|
|
400
476
|
|
|
401
|
-
// FIXME: https://github.com/graphql/graphql-js/issues/2203
|
|
402
|
-
|
|
403
|
-
/* c8 ignore next */
|
|
404
477
|
return (_maybeArray$some =
|
|
405
478
|
maybeArray === null || maybeArray === void 0
|
|
406
479
|
? void 0
|
|
407
|
-
: maybeArray.some((
|
|
480
|
+
: maybeArray.some((result) => result.newlines !== 0)) !== null &&
|
|
408
481
|
_maybeArray$some !== void 0
|
|
409
482
|
? _maybeArray$some
|
|
410
483
|
: false;
|
|
411
484
|
}
|
|
485
|
+
|
|
486
|
+
function wrappedLineAndArgs(prefix, args) {
|
|
487
|
+
if (args == null || args.length === 0) {
|
|
488
|
+
return prefix;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
return join([
|
|
492
|
+
prefix,
|
|
493
|
+
prefix.length + joinedLength(args, ', ') + 2 > MAX_LINE_LENGTH
|
|
494
|
+
? wrap('(\n', join(args, '\n').indent(), '\n)')
|
|
495
|
+
: wrap('(', join(args, ', '), ')'),
|
|
496
|
+
]);
|
|
497
|
+
}
|