Skip to content

Default values not work for notNull fields #274

Closed
@jantajov

Description

@jantajov

Field with type 'notNull' ignores default value and throws error:

"Argument "paging" has invalid value {pageSize: 2}. In field "page": Expected "Int!", found null."

// PagingType.php

$config = [
	'fields' => function () {
		return [
			'page' => [
				'type' => Type::nonNull(Type::int()),
				'defaultValue' => 1,
			],
			'pageSize' => Type::nonNull(Type::int()),
		];
	},
];

With nullable types default value works as expected but then client can pass null value into page field...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions