Skip to content

requireNullableFieldsWithOneof

PropertyValue
Config namerequireNullableFieldsWithOneof
Default severity
ContextSchema
In recommendedNo

Requires all fields in @oneOf input types to be nullable. The @oneOf directive indicates that exactly one field must be provided, so all fields must be optional (nullable). A non-null field would prevent valid @oneOf usage since the caller could never omit it.

# ❌ Bad — non-null fields in @oneOf input type
input UserByInput @oneOf {
id: ID!
email: String!
}
# ✅ Good — all fields are nullable
input UserByInput @oneOf {
id: ID
email: String
username: String
}
extensions:
graphql-analyzer:
lint:
rules:
requireNullableFieldsWithOneof: error