Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix typing for isNonNullType #3597

Merged
merged 1 commit into from
May 19, 2022
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
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export type {
GraphQLAbstractType,
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNullableInputType,
GraphQLNullableOutputType,
yaacovCR marked this conversation as resolved.
Show resolved Hide resolved
GraphQLNamedType,
GraphQLNamedInputType,
GraphQLNamedOutputType,
Expand Down
38 changes: 16 additions & 22 deletions src/type/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,16 @@ export function assertListType(type: unknown): GraphQLList<GraphQLType> {

export function isNonNullType(
type: GraphQLInputType,
): type is GraphQLNonNull<GraphQLInputType>;
): type is GraphQLNonNull<GraphQLNullableInputType>;
export function isNonNullType(
type: GraphQLOutputType,
): type is GraphQLNonNull<GraphQLOutputType>;
): type is GraphQLNonNull<GraphQLNullableOutputType>;
export function isNonNullType(
type: unknown,
): type is GraphQLNonNull<GraphQLType>;
): type is GraphQLNonNull<GraphQLNullableType>;
export function isNonNullType(
type: unknown,
): type is GraphQLNonNull<GraphQLType> {
): type is GraphQLNonNull<GraphQLNullableType> {
return instanceOf(type, GraphQLNonNull);
}

Expand All @@ -206,17 +206,15 @@ export function assertNonNullType(type: unknown): GraphQLNonNull<GraphQLType> {
/**
* These types may be used as input types for arguments and directives.
*/
export type GraphQLInputType =
export type GraphQLNullableInputType =
| GraphQLScalarType
| GraphQLEnumType
| GraphQLInputObjectType
| GraphQLList<GraphQLInputType>
| GraphQLNonNull<
| GraphQLScalarType
| GraphQLEnumType
| GraphQLInputObjectType
| GraphQLList<GraphQLInputType>
>;
| GraphQLList<GraphQLInputType>;

export type GraphQLInputType =
| GraphQLNullableInputType
| GraphQLNonNull<GraphQLNullableInputType>;

export function isInputType(type: unknown): type is GraphQLInputType {
return (
Expand All @@ -237,21 +235,17 @@ export function assertInputType(type: unknown): GraphQLInputType {
/**
* These types may be used as output types as the result of fields.
*/
export type GraphQLOutputType =
export type GraphQLNullableOutputType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<GraphQLOutputType>
| GraphQLNonNull<
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLList<GraphQLOutputType>
>;
| GraphQLList<GraphQLOutputType>;

export type GraphQLOutputType =
| GraphQLNullableOutputType
| GraphQLNonNull<GraphQLNullableOutputType>;

export function isOutputType(type: unknown): type is GraphQLOutputType {
return (
Expand Down
2 changes: 2 additions & 0 deletions src/type/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ export type {
GraphQLAbstractType,
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNullableInputType,
GraphQLNullableOutputType,
GraphQLNamedType,
GraphQLNamedInputType,
GraphQLNamedOutputType,
Expand Down