Skip to content

Commit

Permalink
Be stricter about types
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Feb 12, 2025
1 parent ac213fa commit 2ca574c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 8 additions & 1 deletion src/language/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ export interface SemanticNonNullTypeNode {
/** Type Reference */

export type TypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode;
export type SchemaOutputTypeNode = NamedTypeNode | ListTypeNode | NonNullTypeNode | SemanticNonNullTypeNode;

export interface NamedTypeNode {
readonly kind: Kind.NAMED_TYPE;
Expand All @@ -540,7 +541,13 @@ export interface NamedTypeNode {
export interface ListTypeNode {
readonly kind: Kind.LIST_TYPE;
readonly loc?: Location;
readonly type: TypeNode | SemanticNonNullTypeNode;
readonly type: TypeNode;
}

export interface SchemaListTypeNode {
readonly kind: Kind.LIST_TYPE;
readonly loc?: Location;
readonly type: SchemaOutputTypeNode;
}

export interface NonNullTypeNode {
Expand Down
5 changes: 2 additions & 3 deletions src/utilities/extendSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import type {
ScalarTypeExtensionNode,
SchemaDefinitionNode,
SchemaExtensionNode,
SemanticNonNullTypeNode,
SchemaOutputTypeNode,
TypeDefinitionNode,
TypeNode,
UnionTypeDefinitionNode,
UnionTypeExtensionNode,
} from '../language/ast';
Expand Down Expand Up @@ -433,7 +432,7 @@ export function extendSchemaImpl(
}

function getWrappedType(
node: TypeNode | SemanticNonNullTypeNode,
node: SchemaOutputTypeNode,
): GraphQLType {
if (node.kind === Kind.LIST_TYPE) {
return new GraphQLList(getWrappedType(node.type));
Expand Down

0 comments on commit 2ca574c

Please sign in to comment.