File tree Expand file tree Collapse file tree 4 files changed +7
-4
lines changed
test/unit/should_generate_union_types_properly Expand file tree Collapse file tree 4 files changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { UnionTypeDefinitionNode } from "graphql";
15
15
import { shouldIncludeTypeDefinition } from "../helpers/should-include-type-definition" ;
16
16
import { buildDirectiveAnnotations } from "../helpers/build-directive-annotations" ;
17
17
import { CodegenConfig } from "../plugin" ;
18
+ import { trimDescription } from "../helpers/build-annotations" ;
18
19
19
20
export function buildUnionTypeDefinition (
20
21
node : UnionTypeDefinitionNode ,
@@ -30,7 +31,7 @@ export function buildUnionTypeDefinition(
30
31
return `${ directiveAnnotations } @GraphQLUnion(
31
32
name = "${ node . name . value } ",
32
33
possibleTypes = [${ possibleTypes } ],
33
- description = "${ node . description ?. value ?? "" } "
34
+ description = "${ node . description ?. value ? trimDescription ( node . description . value ) : "" } "
34
35
)
35
36
annotation class ${ node . name . value } ` ;
36
37
}
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ export function isDeprecatedDescription(
95
95
) ;
96
96
}
97
97
98
- function trimDescription ( description : string ) {
98
+ export function trimDescription ( description : string ) {
99
99
return (
100
100
description
101
101
. split ( "\n" )
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ data class MyType2(
14
14
@GraphQLUnion(
15
15
name = " MyUnion" ,
16
16
possibleTypes = [MyType1 ::class , MyType2 ::class ],
17
- description = " A description for MyUnion"
17
+ description = " A trimmed description for MyUnion"
18
18
)
19
19
annotation class MyUnion
20
20
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ type MyType2 {
7
7
field : String
8
8
}
9
9
10
- "A description for MyUnion"
10
+ """
11
+ A "trimmed" description for MyUnion
12
+ """
11
13
union MyUnion = MyType1 | MyType2
12
14
13
15
type MyUnionType {
You can’t perform that action at this time.
0 commit comments