Skip to content

Refactor GraphQL*Type TS types to be more DRY #3598

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

Merged
merged 1 commit into from
May 19, 2022
Merged
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
36 changes: 5 additions & 31 deletions src/type/definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,9 @@ import type { GraphQLSchema } from './schema';
* These are all of the possible kinds of types.
*/
export type GraphQLType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLInputObjectType
| GraphQLNamedType
| GraphQLList<GraphQLType>
| GraphQLNonNull<
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLInputObjectType
| GraphQLList<GraphQLType>
>;
| GraphQLNonNull<GraphQLNullableType>;

export function isType(type: unknown): type is GraphQLType {
return (
Expand Down Expand Up @@ -207,9 +194,7 @@ export function assertNonNullType(type: unknown): GraphQLNonNull<GraphQLType> {
* These types may be used as input types for arguments and directives.
*/
export type GraphQLNullableInputType =
| GraphQLScalarType
| GraphQLEnumType
| GraphQLInputObjectType
| GraphQLNamedInputType
| GraphQLList<GraphQLInputType>;

export type GraphQLInputType =
Expand All @@ -236,11 +221,7 @@ export function assertInputType(type: unknown): GraphQLInputType {
* These types may be used as output types as the result of fields.
*/
export type GraphQLNullableOutputType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLNamedOutputType
| GraphQLList<GraphQLOutputType>;

export type GraphQLOutputType =
Expand Down Expand Up @@ -430,14 +411,7 @@ export function assertWrappingType(type: unknown): GraphQLWrappingType {
/**
* These types can all accept null as a value.
*/
export type GraphQLNullableType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLInputObjectType
| GraphQLList<GraphQLType>;
export type GraphQLNullableType = GraphQLNamedType | GraphQLList<GraphQLType>;

export function isNullableType(type: unknown): type is GraphQLNullableType {
return isType(type) && !isNonNullType(type);
Expand Down