# oneof-fields-nullable

Source: https://api-genie.dev/docs/linter/graphql/rules/oneof-fields-nullable

A rule of the GraphQL linter, which reads GraphQL schemas and operations. Since 0.9.0. In the rulesets: Recommended at error, Strict at error, All at error.

This rule checks that the fields of `@oneOf` input object types are nullable and have no default value.

## Rule details

Exactly one field of a `@oneOf` input object is given; a non-null field or a default value would make every value invalid, as the specification of `@oneOf` requires.

The rule applies to definitions. An `# apigenie-lint-disable oneof-fields-nullable` comment on a
node turns it off for the node and everything nested in it; at the top of the file, separated from
the first definition by a blank line, the comment turns it off for the whole file.

## Examples

**Good**.

```graphql
input UserBy @oneOf { id: ID, email: String }
```

**Bad**. The linter reports `Input field 'UserBy.id' of the @oneOf input object type should be nullable`.

```graphql
input UserBy @oneOf { id: ID!, email: String }
```
