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