Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Document behavior of unions containing unions
Fixes #131
- Loading branch information
1 parent
5899592
commit 6f80cd0
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
src/tests/fixtures/unions/UnionAsMemberOfItself.invalid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** @gqlType */ | ||
export default class SomeType { | ||
/** @gqlField */ | ||
me: Actor; | ||
} | ||
|
||
/** @gqlType */ | ||
class User { | ||
__typename = "User"; | ||
/** @gqlField */ | ||
name: string; | ||
} | ||
|
||
/** @gqlType */ | ||
class Entity { | ||
__typename = "Entity"; | ||
/** @gqlField */ | ||
description: string; | ||
} | ||
|
||
/** @gqlUnion */ | ||
type Actor = User | Entity | Actor; |
33 changes: 33 additions & 0 deletions
33
src/tests/fixtures/unions/UnionAsMemberOfItself.invalid.ts.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlType */ | ||
export default class SomeType { | ||
/** @gqlField */ | ||
me: Actor; | ||
} | ||
|
||
/** @gqlType */ | ||
class User { | ||
__typename = "User"; | ||
/** @gqlField */ | ||
name: string; | ||
} | ||
|
||
/** @gqlType */ | ||
class Entity { | ||
__typename = "Entity"; | ||
/** @gqlField */ | ||
description: string; | ||
} | ||
|
||
/** @gqlUnion */ | ||
type Actor = User | Entity | Actor; | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
src/tests/fixtures/unions/UnionAsMemberOfItself.invalid.ts:22:30 - error: Union type Actor can only include Object types, it cannot include Actor. | ||
|
||
22 type Actor = User | Entity | Actor; | ||
~~~~~ |
32 changes: 32 additions & 0 deletions
32
src/tests/fixtures/unions/UnionAsMemberOfOtherUnion.invalid.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** @gqlType */ | ||
export default class SomeType { | ||
/** @gqlField */ | ||
me: Actor; | ||
} | ||
|
||
/** @gqlType */ | ||
class User { | ||
__typename = "User"; | ||
/** @gqlField */ | ||
name: string; | ||
} | ||
|
||
/** @gqlType */ | ||
class Entity { | ||
__typename = "Entity"; | ||
/** @gqlField */ | ||
description: string; | ||
} | ||
|
||
/** @gqlType */ | ||
class Admin { | ||
__typename = "Admin"; | ||
/** @gqlField */ | ||
description: string; | ||
} | ||
|
||
/** @gqlUnion */ | ||
type Foo = User | Entity; | ||
|
||
/** @gqlUnion */ | ||
type Actor = Admin | Foo; |
43 changes: 43 additions & 0 deletions
43
src/tests/fixtures/unions/UnionAsMemberOfOtherUnion.invalid.ts.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
----------------- | ||
INPUT | ||
----------------- | ||
/** @gqlType */ | ||
export default class SomeType { | ||
/** @gqlField */ | ||
me: Actor; | ||
} | ||
|
||
/** @gqlType */ | ||
class User { | ||
__typename = "User"; | ||
/** @gqlField */ | ||
name: string; | ||
} | ||
|
||
/** @gqlType */ | ||
class Entity { | ||
__typename = "Entity"; | ||
/** @gqlField */ | ||
description: string; | ||
} | ||
|
||
/** @gqlType */ | ||
class Admin { | ||
__typename = "Admin"; | ||
/** @gqlField */ | ||
description: string; | ||
} | ||
|
||
/** @gqlUnion */ | ||
type Foo = User | Entity; | ||
|
||
/** @gqlUnion */ | ||
type Actor = Admin | Foo; | ||
|
||
----------------- | ||
OUTPUT | ||
----------------- | ||
src/tests/fixtures/unions/UnionAsMemberOfOtherUnion.invalid.ts:32:22 - error: Union type Actor can only include Object types, it cannot include Foo. | ||
|
||
32 type Actor = Admin | Foo; | ||
~~~ |