Skip to content

Commit

Permalink
Forbid null & undefined as return value of 'interfaces' thunk (#2951)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Mar 10, 2021
1 parent 1df295e commit 3869211
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/type/definition.d.ts
Expand Up @@ -433,7 +433,7 @@ export function argsToArgsConfig(
export interface GraphQLObjectTypeConfig<TSource, TContext> {
name: string;
description?: Maybe<string>;
interfaces?: Thunk<Maybe<Array<GraphQLInterfaceType>>>;
interfaces?: Thunk<Array<GraphQLInterfaceType>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>;
isTypeOf?: Maybe<GraphQLIsTypeOfFn<TSource, TContext>>;
extensions?: Maybe<Readonly<GraphQLObjectTypeExtensions<TSource, TContext>>>;
Expand Down Expand Up @@ -635,7 +635,7 @@ export class GraphQLInterfaceType {
export interface GraphQLInterfaceTypeConfig<TSource, TContext> {
name: string;
description?: Maybe<string>;
interfaces?: Thunk<Maybe<Array<GraphQLInterfaceType>>>;
interfaces?: Thunk<Array<GraphQLInterfaceType>>;
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>;
/**
* Optionally provide a custom type resolver function. If one is not provided,
Expand Down
6 changes: 3 additions & 3 deletions src/type/definition.js
Expand Up @@ -772,7 +772,7 @@ function defineInterfaces(
| GraphQLInterfaceTypeConfig<mixed, mixed>,
>,
): Array<GraphQLInterfaceType> {
const interfaces = resolveThunk(config.interfaces) ?? [];
const interfaces = resolveThunk(config.interfaces ?? []);
devAssert(
Array.isArray(interfaces),
`${config.name} interfaces must be an Array or a function which returns an Array.`,
Expand Down Expand Up @@ -875,7 +875,7 @@ export function argsToArgsConfig(
export type GraphQLObjectTypeConfig<TSource, TContext> = {|
name: string,
description?: ?string,
interfaces?: Thunk<?Array<GraphQLInterfaceType>>,
interfaces?: Thunk<Array<GraphQLInterfaceType>>,
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>,
isTypeOf?: ?GraphQLIsTypeOfFn<TSource, TContext>,
extensions?: ?ReadOnlyObjMapLike<mixed>,
Expand Down Expand Up @@ -1086,7 +1086,7 @@ export class GraphQLInterfaceType {
export type GraphQLInterfaceTypeConfig<TSource, TContext> = {|
name: string,
description?: ?string,
interfaces?: Thunk<?Array<GraphQLInterfaceType>>,
interfaces?: Thunk<Array<GraphQLInterfaceType>>,
fields: Thunk<GraphQLFieldConfigMap<TSource, TContext>>,
/**
* Optionally provide a custom type resolver function. If one is not provided,
Expand Down

0 comments on commit 3869211

Please sign in to comment.