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 #3410

Merged
merged 1 commit into from Dec 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/index.d.ts
Expand Up @@ -138,6 +138,8 @@ export {
GraphQLNullableType,
GraphQLNamedType,
Thunk,
GraphQLNamedInputType,
GraphQLNamedOutputType,
GraphQLSchemaConfig,
GraphQLSchemaExtensions,
GraphQLDirectiveConfig,
Expand Down
2 changes: 2 additions & 0 deletions src/index.js
Expand Up @@ -137,6 +137,8 @@ export type {
GraphQLNullableType,
GraphQLNamedType,
Thunk,
GraphQLNamedInputType,
GraphQLNamedOutputType,
GraphQLSchemaConfig,
GraphQLDirectiveConfig,
GraphQLArgument,
Expand Down
14 changes: 11 additions & 3 deletions src/type/definition.d.ts
Expand Up @@ -254,19 +254,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: any): type is GraphQLNamedType;

export function assertNamedType(type: any): 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
Expand Up @@ -493,13 +493,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 @@ -521,6 +527,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
Expand Up @@ -74,6 +74,8 @@ export {
GraphQLNullableType,
GraphQLNamedType,
Thunk,
GraphQLNamedInputType,
GraphQLNamedOutputType,
GraphQLArgument,
GraphQLArgumentConfig,
GraphQLArgumentExtensions,
Expand Down
2 changes: 2 additions & 0 deletions src/type/index.js
Expand Up @@ -129,6 +129,8 @@ export type {
GraphQLNullableType,
GraphQLNamedType,
Thunk,
GraphQLNamedInputType,
GraphQLNamedOutputType,
GraphQLArgument,
GraphQLArgumentConfig,
GraphQLEnumTypeConfig,
Expand Down