Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/type/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1337,6 +1337,8 @@ export class GraphQLList<
readonly __kind: symbol;
/** The type wrapped by this list or non-null type. */
readonly ofType: T;
// eslint-disable-next-line @typescript-eslint/no-unused-private-class-members
declare private readonly __GraphQLListTypeBrand: never;

/**
* Creates a GraphQLList instance.
Expand Down Expand Up @@ -1432,6 +1434,8 @@ export class GraphQLNonNull<
readonly __kind: symbol;
/** The type wrapped by this list or non-null type. */
readonly ofType: T;
// eslint-disable-next-line @typescript-eslint/no-unused-private-class-members
declare private readonly __GraphQLNonNullTypeBrand: never;

/**
* Creates a GraphQLNonNull instance.
Expand Down
5 changes: 4 additions & 1 deletion src/utilities/extendSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import type {
GraphQLFieldNormalizedConfigMap,
GraphQLInputFieldNormalizedConfigMap,
GraphQLNamedType,
GraphQLNullableType,
GraphQLType,
} from '../type/definition.ts';
import {
Expand Down Expand Up @@ -413,7 +414,9 @@ export function extendSchemaImpl(
return new GraphQLList(typeFromAST(node.type));
}
if (node.kind === Kind.NON_NULL_TYPE) {
return new GraphQLNonNull(typeFromAST(node.type));
return new GraphQLNonNull(
typeFromAST(node.type) as GraphQLNullableType,
);
}
return namedTypeFromAST(node);
}
Expand Down
10 changes: 8 additions & 2 deletions src/utilities/typeFromAST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import type {
} from '../language/ast.ts';
import { Kind } from '../language/kinds.ts';

import type { GraphQLNamedType, GraphQLType } from '../type/definition.ts';
import type {
GraphQLNamedType,
GraphQLNullableType,
GraphQLType,
} from '../type/definition.ts';
import { GraphQLList, GraphQLNonNull } from '../type/definition.ts';
import type { GraphQLSchema } from '../type/schema.ts';

Expand Down Expand Up @@ -134,7 +138,9 @@ export function typeFromAST(
return innerType && new GraphQLList(innerType);
}
case Kind.NON_NULL_TYPE: {
const innerType = typeFromAST(schema, typeNode.type);
const innerType = typeFromAST(schema, typeNode.type) as
| GraphQLNullableType
| undefined;
return innerType && new GraphQLNonNull(innerType);
}
case Kind.NAMED_TYPE:
Expand Down
Loading