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

Refine getNamedType() for Input and Output types #3063

Merged
merged 1 commit into from
May 6, 2021
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.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export {
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNamedType,
GraphQLNamedInputType,
GraphQLNamedOutputType,
ThunkArray,
ThunkObjMap,
GraphQLSchemaConfig,
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ export type {
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNamedType,
GraphQLNamedInputType,
GraphQLNamedOutputType,
ThunkArray,
ThunkObjMap,
GraphQLSchemaConfig,
Expand Down
14 changes: 11 additions & 3 deletions src/type/definition.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,19 +249,27 @@ export function getNullableType<T extends GraphQLNullableType>(
/**
* These named types do not include modifiers like List or NonNull.
*/
export type GraphQLNamedType =
export type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;

export type GraphQLNamedInputType =
| GraphQLScalarType
| GraphQLEnumType
| GraphQLInputObjectType;

export type GraphQLNamedOutputType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLInputObjectType;
| GraphQLEnumType;

export function isNamedType(type: unknown): type is GraphQLNamedType;

export function assertNamedType(type: unknown): GraphQLNamedType;

export function getNamedType(type: undefined): undefined;
export function getNamedType(type: GraphQLInputType): GraphQLNamedInputType;
export function getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType;
export function getNamedType(type: GraphQLType): GraphQLNamedType;

/**
Expand Down
14 changes: 11 additions & 3 deletions src/type/definition.js
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,19 @@ export function getNullableType(type) {
/**
* These named types do not include modifiers like List or NonNull.
*/
export type GraphQLNamedType =
export type GraphQLNamedType = GraphQLNamedInputType | GraphQLNamedOutputType;

export type GraphQLNamedInputType =
| GraphQLScalarType
| GraphQLEnumType
| GraphQLInputObjectType;

export type GraphQLNamedOutputType =
| GraphQLScalarType
| GraphQLObjectType
| GraphQLInterfaceType
| GraphQLUnionType
| GraphQLEnumType
| GraphQLInputObjectType;
| GraphQLEnumType;

export function isNamedType(type: mixed): boolean %checks {
return (
Expand All @@ -495,6 +501,8 @@ export function assertNamedType(type: mixed): GraphQLNamedType {

/* eslint-disable no-redeclare */
declare function getNamedType(type: void | null): void;
declare function getNamedType(type: GraphQLInputType): GraphQLNamedInputType;
declare function getNamedType(type: GraphQLOutputType): GraphQLNamedOutputType;
declare function getNamedType(type: GraphQLType): GraphQLNamedType;
export function getNamedType(type) {
/* eslint-enable no-redeclare */
Expand Down
2 changes: 2 additions & 0 deletions src/type/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ export {
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNamedType,
GraphQLNamedInputType,
GraphQLNamedOutputType,
ThunkArray,
ThunkObjMap,
GraphQLArgument,
Expand Down
2 changes: 2 additions & 0 deletions src/type/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export type {
GraphQLWrappingType,
GraphQLNullableType,
GraphQLNamedType,
GraphQLNamedInputType,
GraphQLNamedOutputType,
ThunkArray,
ThunkObjMap,
GraphQLArgument,
Expand Down