Skip to content

Commit aba2bbb

Browse files
committed
Lint files
1 parent 7819043 commit aba2bbb

File tree

9 files changed

+81
-32
lines changed

9 files changed

+81
-32
lines changed

src/execution/collectFields.ts

+12-4
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export function collectFields(
5151
selectionSet,
5252
fields,
5353
new Set(),
54-
undefined
54+
undefined,
5555
);
5656
return fields;
5757
}
@@ -111,9 +111,17 @@ function collectFieldsImpl(
111111
const name = getFieldEntryKey(selection);
112112
const fieldList = fields.get(name);
113113
if (fieldList !== undefined) {
114-
fieldList.push({ node: selection, fragmentVariableValues: localVariableValues ?? undefined });
114+
fieldList.push({
115+
node: selection,
116+
fragmentVariableValues: localVariableValues ?? undefined,
117+
});
115118
} else {
116-
fields.set(name, [{ node: selection, fragmentVariableValues: localVariableValues ?? undefined }]);
119+
fields.set(name, [
120+
{
121+
node: selection,
122+
fragmentVariableValues: localVariableValues ?? undefined,
123+
},
124+
]);
117125
}
118126
break;
119127
}
@@ -179,7 +187,7 @@ function collectFieldsImpl(
179187
fragment.selectionSet,
180188
fields,
181189
visitedFragmentNames,
182-
fragmentVariableValues
190+
fragmentVariableValues,
183191
);
184192
break;
185193
}

src/execution/execute.ts

+38-11
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ import {
5252
import type { GraphQLSchema } from '../type/schema';
5353
import { assertValidSchema } from '../type/validate';
5454

55+
import type { FieldDetails } from './collectFields';
5556
import {
5657
collectFields,
5758
collectSubfields as _collectSubfields,
58-
FieldDetails,
5959
} from './collectFields';
6060
import { getArgumentValues, getVariableValues } from './values';
6161

@@ -523,7 +523,7 @@ function executeField(
523523
fieldEntries[0].node,
524524
fieldDef.args,
525525
exeContext.variableValues,
526-
fieldEntries[0].fragmentVariableValues
526+
fieldEntries[0].fragmentVariableValues,
527527
);
528528

529529
// The resolve function's optional third argument is a context value that
@@ -536,7 +536,14 @@ function executeField(
536536
let completed;
537537
if (isPromise(result)) {
538538
completed = result.then((resolved) =>
539-
completeValue(exeContext, returnType, fieldEntries, info, path, resolved),
539+
completeValue(
540+
exeContext,
541+
returnType,
542+
fieldEntries,
543+
info,
544+
path,
545+
resolved,
546+
),
540547
);
541548
} else {
542549
completed = completeValue(
@@ -553,13 +560,21 @@ function executeField(
553560
// Note: we don't rely on a `catch` method, but we do expect "thenable"
554561
// to take a second callback for the error case.
555562
return completed.then(undefined, (rawError) => {
556-
const error = locatedError(rawError, fieldEntries.map(entry => entry.node), pathToArray(path));
563+
const error = locatedError(
564+
rawError,
565+
fieldEntries.map((entry) => entry.node),
566+
pathToArray(path),
567+
);
557568
return handleFieldError(error, returnType, exeContext);
558569
});
559570
}
560571
return completed;
561572
} catch (rawError) {
562-
const error = locatedError(rawError, fieldEntries.map(entry => entry.node), pathToArray(path));
573+
const error = locatedError(
574+
rawError,
575+
fieldEntries.map((entry) => entry.node),
576+
pathToArray(path),
577+
);
563578
return handleFieldError(error, returnType, exeContext);
564579
}
565580
}
@@ -578,7 +593,7 @@ export function buildResolveInfo(
578593
// information about the current execution state.
579594
return {
580595
fieldName: fieldDef.name,
581-
fieldNodes: fieldEntries.map(entry => entry.node),
596+
fieldNodes: fieldEntries.map((entry) => entry.node),
582597
returnType: fieldDef.type,
583598
parentType,
584599
path,
@@ -772,15 +787,19 @@ function completeListValue(
772787
return completedItem.then(undefined, (rawError) => {
773788
const error = locatedError(
774789
rawError,
775-
fieldEntries.map(entry => entry.node),
790+
fieldEntries.map((entry) => entry.node),
776791
pathToArray(itemPath),
777792
);
778793
return handleFieldError(error, itemType, exeContext);
779794
});
780795
}
781796
return completedItem;
782797
} catch (rawError) {
783-
const error = locatedError(rawError, fieldEntries.map(entry => entry.node), pathToArray(itemPath));
798+
const error = locatedError(
799+
rawError,
800+
fieldEntries.map((entry) => entry.node),
801+
pathToArray(itemPath),
802+
);
784803
return handleFieldError(error, itemType, exeContext);
785804
}
786805
});
@@ -822,7 +841,7 @@ function completeAbstractValue(
822841
const contextValue = exeContext.contextValue;
823842
const runtimeType = resolveTypeFn(result, contextValue, info, returnType);
824843

825-
const fieldNodes = fieldEntries.map(entry => entry.node)
844+
const fieldNodes = fieldEntries.map((entry) => entry.node);
826845
if (isPromise(runtimeType)) {
827846
return runtimeType.then((resolvedRuntimeType) =>
828847
completeObjectValue(
@@ -938,7 +957,11 @@ function completeObjectValue(
938957
if (isPromise(isTypeOf)) {
939958
return isTypeOf.then((resolvedIsTypeOf) => {
940959
if (!resolvedIsTypeOf) {
941-
throw invalidReturnTypeError(returnType, result, fieldEntries.map(entry => entry.node));
960+
throw invalidReturnTypeError(
961+
returnType,
962+
result,
963+
fieldEntries.map((entry) => entry.node),
964+
);
942965
}
943966
return executeFields(
944967
exeContext,
@@ -951,7 +974,11 @@ function completeObjectValue(
951974
}
952975

953976
if (!isTypeOf) {
954-
throw invalidReturnTypeError(returnType, result, fieldEntries.map(entry => entry.node));
977+
throw invalidReturnTypeError(
978+
returnType,
979+
result,
980+
fieldEntries.map((entry) => entry.node),
981+
);
955982
}
956983
}
957984

src/execution/subscribe.ts

+11-3
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ async function executeSubscription(
221221
const fieldName = fieldEntries[0].node.name.value;
222222
throw new GraphQLError(
223223
`The subscription field "${fieldName}" is not defined.`,
224-
{ nodes: fieldEntries.map(entry => entry.node) },
224+
{ nodes: fieldEntries.map((entry) => entry.node) },
225225
);
226226
}
227227

@@ -240,7 +240,11 @@ async function executeSubscription(
240240

241241
// Build a JS object of arguments from the field.arguments AST, using the
242242
// variables scope to fulfill any variable references.
243-
const args = getArgumentValues(fieldEntries[0].node, fieldDef.args, variableValues);
243+
const args = getArgumentValues(
244+
fieldEntries[0].node,
245+
fieldDef.args,
246+
variableValues,
247+
);
244248

245249
// The resolve function's optional third argument is a context value that
246250
// is provided to every resolve function within an execution. It is commonly
@@ -257,6 +261,10 @@ async function executeSubscription(
257261
}
258262
return eventStream;
259263
} catch (error) {
260-
throw locatedError(error, fieldEntries.map(entry => entry.node), pathToArray(path));
264+
throw locatedError(
265+
error,
266+
fieldEntries.map((entry) => entry.node),
267+
pathToArray(path),
268+
);
261269
}
262270
}

src/execution/values.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ import type {
1515
import { Kind } from '../language/kinds';
1616
import { print } from '../language/printer';
1717

18-
import type { GraphQLArgument, GraphQLField } from '../type/definition';
18+
import type { GraphQLArgument } from '../type/definition';
1919
import { isInputType, isNonNullType } from '../type/definition';
2020
import type { GraphQLDirective } from '../type/directives';
2121
import type { GraphQLSchema } from '../type/schema';
2222

2323
import { coerceInputValue } from '../utilities/coerceInputValue';
2424
import { typeFromAST } from '../utilities/typeFromAST';
2525
import { valueFromAST } from '../utilities/valueFromAST';
26-
import { valueFromASTUntyped } from '../utilities';
26+
import { valueFromASTUntyped } from '../utilities/valueFromASTUntyped';
2727

2828
type CoercedVariableValues =
2929
| { errors: ReadonlyArray<GraphQLError>; coerced?: never }
@@ -191,12 +191,15 @@ export function getArgumentValues(
191191
fragmentArgValues != null &&
192192
hasOwnProperty(fragmentArgValues, variableName)
193193
) {
194-
hasValue = fragmentArgValues![variableName] != null;
194+
hasValue = fragmentArgValues[variableName] != null;
195195
if (!hasValue && argDef.defaultValue !== undefined) {
196196
coercedValues[name] = argDef.defaultValue;
197197
continue;
198198
}
199-
} else if (variableValues != null && hasOwnProperty(variableValues, variableName)) {
199+
} else if (
200+
variableValues != null &&
201+
hasOwnProperty(variableValues, variableName)
202+
) {
200203
hasValue = variableValues[variableName] != null;
201204
} else if (argDef.defaultValue !== undefined) {
202205
coercedValues[name] = argDef.defaultValue;
@@ -248,7 +251,7 @@ export function getArgumentValuesFromSpread(
248251
fragmentArgValues?: Maybe<ObjMap<unknown>>,
249252
): { [argument: string]: unknown } {
250253
const coercedValues: { [argument: string]: unknown } = {};
251-
const argNodeMap = keyMap(node?.arguments || [], (arg) => arg.name.value);
254+
const argNodeMap = keyMap(node?.arguments ?? [], (arg) => arg.name.value);
252255

253256
for (const varDef of fragmentVarDefs) {
254257
const name = varDef.variable.name.value;

src/language/__tests__/printer-test.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ describe('Printer: Query document', () => {
239239
c: "a long string extending arguments over max length"
240240
)
241241
}
242-
`
243-
);
242+
`);
244243
});
245244
});

src/language/parser.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export interface ParseOptions {
123123
* }
124124
* ```
125125
*/
126-
experimentalFragmentArguments?: boolean | undefined;
126+
experimentalFragmentArguments?: boolean | undefined;
127127
}
128128

129129
/**
@@ -555,13 +555,13 @@ export class Parser {
555555
kind: Kind.FRAGMENT_DEFINITION,
556556
name: this.parseFragmentName(),
557557
variableDefinitions:
558-
this._options.experimentalFragmentArguments === true || this._options.allowLegacyFragmentVariables === true
558+
this._options.experimentalFragmentArguments === true ||
559+
this._options.allowLegacyFragmentVariables === true
559560
? this.parseVariableDefinitions()
560561
: undefined,
561562
typeCondition: (this.expectKeyword('on'), this.parseNamedType()),
562563
directives: this.parseDirectives(false),
563564
selectionSet: this.parseSelectionSet(),
564-
565565
});
566566
}
567567

src/language/printer.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ const printDocASTReducer: ASTReducer<string> = {
5858
leave({ alias, name, arguments: args, directives, selectionSet }) {
5959
const prefix = wrap('', alias, ': ') + name;
6060

61-
return join([wrappedLineAndArgs(prefix, args), join(directives, ' '), selectionSet], ' ');
61+
return join(
62+
[wrappedLineAndArgs(prefix, args), join(directives, ' '), selectionSet],
63+
' ',
64+
);
6265
},
6366
},
6467

src/utilities/TypeInfo.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ export class TypeInfo {
228228
if (directive) {
229229
argDef = directive.args.find((arg) => arg.name === node.name.value);
230230
} else if (fragmentSpread) {
231-
const fragmentDef = this._fragmentDefinitions[fragmentSpread.name.value]
231+
const fragmentDef =
232+
this._fragmentDefinitions[fragmentSpread.name.value];
232233
const fragVarDef = fragmentDef?.variableDefinitions?.find(
233234
(varDef) => varDef.variable.name.value === node.name.value,
234235
);

src/validation/rules/SingleFieldSubscriptionsRule.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function SingleFieldSubscriptionsRule(
5757
operationName != null
5858
? `Subscription "${operationName}" must select only one top level field.`
5959
: 'Anonymous Subscription must select only one top level field.',
60-
{ nodes: extraFieldSelections.map(entry => entry.node) },
60+
{ nodes: extraFieldSelections.map((entry) => entry.node) },
6161
),
6262
);
6363
}
@@ -70,7 +70,7 @@ export function SingleFieldSubscriptionsRule(
7070
operationName != null
7171
? `Subscription "${operationName}" must not select an introspection top level field.`
7272
: 'Anonymous Subscription must not select an introspection top level field.',
73-
{ nodes: fieldNodes.map(entry => entry.node) },
73+
{ nodes: fieldNodes.map((entry) => entry.node) },
7474
),
7575
);
7676
}

0 commit comments

Comments
 (0)