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";
1515import { shouldIncludeTypeDefinition } from "../helpers/should-include-type-definition" ;
1616import { buildDirectiveAnnotations } from "../helpers/build-directive-annotations" ;
1717import { CodegenConfig } from "../plugin" ;
18+ import { trimDescription } from "../helpers/build-annotations" ;
1819
1920export function buildUnionTypeDefinition (
2021 node : UnionTypeDefinitionNode ,
@@ -30,7 +31,7 @@ export function buildUnionTypeDefinition(
3031 return `${ directiveAnnotations } @GraphQLUnion(
3132 name = "${ node . name . value } ",
3233 possibleTypes = [${ possibleTypes } ],
33- description = "${ node . description ?. value ?? "" } "
34+ description = "${ node . description ?. value ? trimDescription ( node . description . value ) : "" } "
3435)
3536annotation class ${ node . name . value } ` ;
3637}
Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ export function isDeprecatedDescription(
9595 ) ;
9696}
9797
98- function trimDescription ( description : string ) {
98+ export function trimDescription ( description : string ) {
9999 return (
100100 description
101101 . split ( "\n" )
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ data class MyType2(
1414@GraphQLUnion(
1515 name = " MyUnion" ,
1616 possibleTypes = [MyType1 ::class , MyType2 ::class ],
17- description = " A description for MyUnion"
17+ description = " A trimmed description for MyUnion"
1818)
1919annotation class MyUnion
2020
Original file line number Diff line number Diff line change @@ -7,7 +7,9 @@ type MyType2 {
77 field : String
88}
99
10- "A description for MyUnion"
10+ """
11+ A "trimmed" description for MyUnion
12+ """
1113union MyUnion = MyType1 | MyType2
1214
1315type MyUnionType {
You can’t perform that action at this time.
0 commit comments