Skip to content

requireTypePatternWithOneof

Property Value
Config name requireTypePatternWithOneof
Default severity
Context Schema
In recommended No

Enforces that types annotated with the @oneOf directive follow a result pattern by requiring both ok and error fields. This standardizes mutation result types so that both success and failure cases are always represented.

The rule applies to any type (object or input) that has the @oneOf directive. If either the ok or error field is missing, a warning is reported on the type name.

# ❌ Bad — @oneOf type missing the error field
type DoSomethingResult @oneOf {
ok: DoSomethingSuccess
}
# ❌ Bad — @oneOf type missing both ok and error fields
type DoSomethingResult @oneOf {
success: DoSomethingSuccess
failure: Error
}
# ✅ Good — @oneOf type with both ok and error
type DoSomethingResult @oneOf {
ok: DoSomethingSuccess
error: Error
}
extensions:
graphql-analyzer:
lint:
rules:
requireTypePatternWithOneof: warn