Skip to content

Commit

Permalink
TS: Fix strict issues in src/execution
Browse files Browse the repository at this point in the history
  • Loading branch information
leebyron committed May 27, 2021
1 parent e1887c7 commit 627b258
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/execution/__tests__/executor-test.ts
Expand Up @@ -94,7 +94,7 @@ describe('Execute: Handles basic execution tasks', () => {
return Promise.resolve(data);
}

const DataType = new GraphQLObjectType({
const DataType: GraphQLObjectType = new GraphQLObjectType({
name: 'DataType',
fields: () => ({
a: { type: GraphQLString },
Expand Down Expand Up @@ -185,7 +185,7 @@ describe('Execute: Handles basic execution tasks', () => {
});

it('merges parallel fragments', () => {
const Type = new GraphQLObjectType({
const Type: GraphQLObjectType = new GraphQLObjectType({
name: 'Type',
fields: () => ({
a: { type: GraphQLString, resolve: () => 'Apple' },
Expand Down Expand Up @@ -624,7 +624,7 @@ describe('Execute: Handles basic execution tasks', () => {
});

it('Full response path is included for non-nullable fields', () => {
const A = new GraphQLObjectType({
const A: GraphQLObjectType = new GraphQLObjectType({
name: 'A',
fields: () => ({
nullableA: {
Expand Down
2 changes: 1 addition & 1 deletion src/execution/__tests__/schema-test.ts
Expand Up @@ -29,7 +29,7 @@ describe('Execute: Handles execution with a complex schema', () => {
},
});

const BlogAuthor = new GraphQLObjectType({
const BlogAuthor: GraphQLObjectType = new GraphQLObjectType({
name: 'Author',
fields: () => ({
id: { type: GraphQLString },
Expand Down
14 changes: 7 additions & 7 deletions src/execution/__tests__/union-interface-test.ts
Expand Up @@ -65,14 +65,14 @@ const NamedType = new GraphQLInterfaceType({
},
});

const LifeType = new GraphQLInterfaceType({
const LifeType: GraphQLInterfaceType = new GraphQLInterfaceType({
name: 'Life',
fields: () => ({
progeny: { type: new GraphQLList(LifeType) },
}),
});

const MammalType = new GraphQLInterfaceType({
const MammalType: GraphQLInterfaceType = new GraphQLInterfaceType({
name: 'Mammal',
interfaces: [LifeType],
fields: () => ({
Expand All @@ -82,7 +82,7 @@ const MammalType = new GraphQLInterfaceType({
}),
});

const DogType = new GraphQLObjectType({
const DogType: GraphQLObjectType = new GraphQLObjectType({
name: 'Dog',
interfaces: [MammalType, LifeType, NamedType],
fields: () => ({
Expand All @@ -95,7 +95,7 @@ const DogType = new GraphQLObjectType({
isTypeOf: (value) => value instanceof Dog,
});

const CatType = new GraphQLObjectType({
const CatType: GraphQLObjectType = new GraphQLObjectType({
name: 'Cat',
interfaces: [MammalType, LifeType, NamedType],
fields: () => ({
Expand Down Expand Up @@ -125,7 +125,7 @@ const PetType = new GraphQLUnionType({
},
});

const PersonType = new GraphQLObjectType({
const PersonType: GraphQLObjectType = new GraphQLObjectType({
name: 'Person',
interfaces: [NamedType, MammalType, LifeType],
fields: () => ({
Expand Down Expand Up @@ -503,7 +503,7 @@ describe('Execute: Union and intersection types', () => {
let encounteredSchema;
let encounteredRootValue;

const NamedType2 = new GraphQLInterfaceType({
const NamedType2: GraphQLInterfaceType = new GraphQLInterfaceType({
name: 'Named',
fields: {
name: { type: GraphQLString },
Expand All @@ -516,7 +516,7 @@ describe('Execute: Union and intersection types', () => {
},
});

const PersonType2 = new GraphQLObjectType({
const PersonType2: GraphQLObjectType = new GraphQLObjectType({
name: 'Person',
interfaces: [NamedType2],
fields: {
Expand Down
9 changes: 7 additions & 2 deletions src/execution/__tests__/variables-test.ts
Expand Up @@ -7,7 +7,10 @@ import { invariant } from '../../jsutils/invariant';
import { Kind } from '../../language/kinds';
import { parse } from '../../language/parser';

import type { GraphQLArgumentConfig } from '../../type/definition';
import type {
GraphQLFieldConfig,
GraphQLArgumentConfig,
} from '../../type/definition';
import { GraphQLSchema } from '../../type/schema';
import { GraphQLString } from '../../type/scalars';
import {
Expand Down Expand Up @@ -64,7 +67,9 @@ const TestEnum = new GraphQLEnumType({
},
});

function fieldWithInputArg(inputArg: GraphQLArgumentConfig) {
function fieldWithInputArg(
inputArg: GraphQLArgumentConfig,
): GraphQLFieldConfig<any, any> {
return {
type: GraphQLString,
args: { input: inputArg },
Expand Down
4 changes: 2 additions & 2 deletions src/execution/values.ts
Expand Up @@ -77,7 +77,7 @@ function coerceVariableValues(
inputs: { readonly [variable: string]: unknown },
onError: (error: GraphQLError) => void,
): { [variable: string]: unknown } {
const coercedValues = {};
const coercedValues: { [variable: string]: unknown } = {};
for (const varDefNode of varDefNodes) {
const varName = varDefNode.variable.name.value;
const varType = typeFromAST(schema, varDefNode.type);
Expand Down Expand Up @@ -162,7 +162,7 @@ export function getArgumentValues(
node: FieldNode | DirectiveNode,
variableValues?: Maybe<ObjMap<unknown>>,
): { [argument: string]: unknown } {
const coercedValues = {};
const coercedValues: { [argument: string]: unknown } = {};

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

0 comments on commit 627b258

Please sign in to comment.