Skip to content

Commit 61d6f8c

Browse files
committed
remove devAsserts that duplicate TS types
see graphql#3642
1 parent 935b79c commit 61d6f8c

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

src/type/definition.ts

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -943,32 +943,20 @@ export class GraphQLField<
943943
config: GraphQLFieldConfig<TSource, TContext, TArgs>,
944944
) {
945945
const coordinate = `${parentCoordinate}.${name}`;
946-
947-
devAssert(
948-
isPlainObj(config),
949-
`${coordinate} field config must be an object.`,
950-
);
951-
952-
devAssert(
953-
config.resolve == null || typeof config.resolve === 'function',
954-
`${coordinate} field resolver must be a function if ` +
955-
`provided, but got: ${inspect(config.resolve)}.`,
956-
);
957-
958-
const argsConfig = config.args ?? {};
959-
devAssert(
960-
isPlainObj(argsConfig),
961-
`${coordinate} args must be an object with argument names as keys.`,
962-
);
963-
964946
super(coordinate);
947+
965948
this.name = assertName(name);
966949
this.description = config.description;
967950
this.type = config.type;
968-
this.args = Object.entries(argsConfig).map(
969-
([argName, argConfig]) =>
970-
new GraphQLArgument(coordinate, argName, argConfig),
971-
);
951+
952+
const argsConfig = config.args;
953+
this.args = argsConfig
954+
? Object.entries(argsConfig).map(
955+
([argName, argConfig]) =>
956+
new GraphQLArgument(coordinate, argName, argConfig),
957+
)
958+
: [];
959+
972960
this.resolve = config.resolve;
973961
this.subscribe = config.subscribe;
974962
this.deprecationReason = config.deprecationReason;

0 commit comments

Comments
 (0)