eslint-plugin-type-graphql
Version:
Linter for TypeGraphQL decorators
60 lines (48 loc) • 1.05 kB
Markdown
# Warns when the decorator is configured incorrectly<br/>(`invalid-decorated-type`)
## Rule Details
This rule will warn when a type is decorated with TypeGraphQL that is not expressable in GraphQL.
Examples of **incorrect** code for this rule:
```ts
// Union types are only supported in GraphQL when made explicit using TypeGraphQL unions
myUnion!: string | boolean;
```
```ts
// Two dimensional arrays require nested objects
coordinates(): number[][]{
return [
[0, 0.5],
[5.2, 1.2]
];
}
```
Examples of **correct** code for this rule:
```ts
// Inside MyUnion.ts
const MyUnion = createUnionType({
name: "MyUnion",
types: () => [MyType1, MyType2] as const
})
// Inside other class
myUnion!: MyUnion;
```
```ts
// Inside Coordinate.ts
class Coordinate{
x!: number;
y!: number;
}
// Inside resolver
coordinates(){
return [
{ x: 0, y: 0.5 },
{ x: 5.2, y: 1.2 }
];
}
```