requireTypePatternWithOneof
| Property | Value |
|---|---|
| Config name | requireTypePatternWithOneof |
| Default severity | — |
| Context | Schema |
| In recommended | No |
What it checks
Section titled “What it checks”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.
Examples
Section titled “Examples”# ❌ Bad — @oneOf type missing the error fieldtype DoSomethingResult @oneOf { ok: DoSomethingSuccess}# ❌ Bad — @oneOf type missing both ok and error fieldstype DoSomethingResult @oneOf { success: DoSomethingSuccess failure: Error}# ✅ Good — @oneOf type with both ok and errortype DoSomethingResult @oneOf { ok: DoSomethingSuccess error: Error}Configuration
Section titled “Configuration”extensions: graphql-analyzer: lint: rules: requireTypePatternWithOneof: warn