Skip to content

Commit 8066ac9

Browse files
committed
TS: Fix strict issues in src/execution
1 parent 26bf00a commit 8066ac9

File tree

6 files changed

+21
-18
lines changed

6 files changed

+21
-18
lines changed

src/execution/__tests__/executor-test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('Execute: Handles basic execution tasks', () => {
9494
return Promise.resolve(data);
9595
}
9696

97-
const DataType = new GraphQLObjectType({
97+
const DataType: GraphQLObjectType = new GraphQLObjectType({
9898
name: 'DataType',
9999
fields: () => ({
100100
a: { type: GraphQLString },
@@ -185,7 +185,7 @@ describe('Execute: Handles basic execution tasks', () => {
185185
});
186186

187187
it('merges parallel fragments', () => {
188-
const Type = new GraphQLObjectType({
188+
const Type: GraphQLObjectType = new GraphQLObjectType({
189189
name: 'Type',
190190
fields: () => ({
191191
a: { type: GraphQLString, resolve: () => 'Apple' },
@@ -624,7 +624,7 @@ describe('Execute: Handles basic execution tasks', () => {
624624
});
625625

626626
it('Full response path is included for non-nullable fields', () => {
627-
const A = new GraphQLObjectType({
627+
const A: GraphQLObjectType = new GraphQLObjectType({
628628
name: 'A',
629629
fields: () => ({
630630
nullableA: {

src/execution/__tests__/schema-test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('Execute: Handles execution with a complex schema', () => {
2929
},
3030
});
3131

32-
const BlogAuthor = new GraphQLObjectType({
32+
const BlogAuthor: GraphQLObjectType = new GraphQLObjectType({
3333
name: 'Author',
3434
fields: () => ({
3535
id: { type: GraphQLString },

src/execution/__tests__/union-interface-test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ const NamedType = new GraphQLInterfaceType({
6565
},
6666
});
6767

68-
const LifeType = new GraphQLInterfaceType({
68+
const LifeType: GraphQLInterfaceType = new GraphQLInterfaceType({
6969
name: 'Life',
7070
fields: () => ({
7171
progeny: { type: new GraphQLList(LifeType) },
7272
}),
7373
});
7474

75-
const MammalType = new GraphQLInterfaceType({
75+
const MammalType: GraphQLInterfaceType = new GraphQLInterfaceType({
7676
name: 'Mammal',
7777
interfaces: [LifeType],
7878
fields: () => ({
@@ -82,7 +82,7 @@ const MammalType = new GraphQLInterfaceType({
8282
}),
8383
});
8484

85-
const DogType = new GraphQLObjectType({
85+
const DogType: GraphQLObjectType = new GraphQLObjectType({
8686
name: 'Dog',
8787
interfaces: [MammalType, LifeType, NamedType],
8888
fields: () => ({
@@ -95,7 +95,7 @@ const DogType = new GraphQLObjectType({
9595
isTypeOf: (value) => value instanceof Dog,
9696
});
9797

98-
const CatType = new GraphQLObjectType({
98+
const CatType: GraphQLObjectType = new GraphQLObjectType({
9999
name: 'Cat',
100100
interfaces: [MammalType, LifeType, NamedType],
101101
fields: () => ({
@@ -125,7 +125,7 @@ const PetType = new GraphQLUnionType({
125125
},
126126
});
127127

128-
const PersonType = new GraphQLObjectType({
128+
const PersonType: GraphQLObjectType = new GraphQLObjectType({
129129
name: 'Person',
130130
interfaces: [NamedType, MammalType, LifeType],
131131
fields: () => ({
@@ -503,7 +503,7 @@ describe('Execute: Union and intersection types', () => {
503503
let encounteredSchema;
504504
let encounteredRootValue;
505505

506-
const NamedType2 = new GraphQLInterfaceType({
506+
const NamedType2: GraphQLInterfaceType = new GraphQLInterfaceType({
507507
name: 'Named',
508508
fields: {
509509
name: { type: GraphQLString },
@@ -516,7 +516,7 @@ describe('Execute: Union and intersection types', () => {
516516
},
517517
});
518518

519-
const PersonType2 = new GraphQLObjectType({
519+
const PersonType2: GraphQLObjectType = new GraphQLObjectType({
520520
name: 'Person',
521521
interfaces: [NamedType2],
522522
fields: {

src/execution/__tests__/variables-test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { invariant } from '../../jsutils/invariant';
77
import { Kind } from '../../language/kinds';
88
import { parse } from '../../language/parser';
99

10-
import type { GraphQLArgumentConfig } from '../../type/definition';
10+
import type {
11+
GraphQLFieldConfig,
12+
GraphQLArgumentConfig,
13+
} from '../../type/definition';
1114
import { GraphQLSchema } from '../../type/schema';
1215
import { GraphQLString } from '../../type/scalars';
1316
import {
@@ -64,7 +67,9 @@ const TestEnum = new GraphQLEnumType({
6467
},
6568
});
6669

67-
function fieldWithInputArg(inputArg: GraphQLArgumentConfig) {
70+
function fieldWithInputArg(
71+
inputArg: GraphQLArgumentConfig,
72+
): GraphQLFieldConfig<any, any> {
6873
return {
6974
type: GraphQLString,
7075
args: { input: inputArg },

src/execution/execute.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
180180
);
181181

182182
// Return early errors if execution context failed.
183-
if (Array.isArray(exeContext)) {
183+
if (!('schema' in exeContext)) {
184184
return { errors: exeContext };
185185
}
186186

@@ -191,9 +191,7 @@ export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
191191
// field and its descendants will be omitted, and sibling fields will still
192192
// be executed. An execution which encounters errors will still result in a
193193
// resolved Promise.
194-
// @ts-expect-error FIXME: TS Conversion
195194
const data = executeOperation(exeContext, exeContext.operation, rootValue);
196-
// @ts-expect-error FIXME: TS Conversion
197195
return buildResponse(exeContext, data);
198196
}
199197

src/execution/values.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function coerceVariableValues(
7777
inputs: { readonly [variable: string]: unknown },
7878
onError: (error: GraphQLError) => void,
7979
): { [variable: string]: unknown } {
80-
const coercedValues = {};
80+
const coercedValues: { [variable: string]: unknown } = {};
8181
for (const varDefNode of varDefNodes) {
8282
const varName = varDefNode.variable.name.value;
8383
const varType = typeFromAST(schema, varDefNode.type);
@@ -162,7 +162,7 @@ export function getArgumentValues(
162162
node: FieldNode | DirectiveNode,
163163
variableValues?: Maybe<ObjMap<unknown>>,
164164
): { [argument: string]: unknown } {
165-
const coercedValues = {};
165+
const coercedValues: { [argument: string]: unknown } = {};
166166

167167
// istanbul ignore next (See: 'https://github.com/graphql/graphql-js/issues/2203')
168168
const argumentNodes = node.arguments ?? [];

0 commit comments

Comments
 (0)