File tree Expand file tree Collapse file tree 4 files changed +41
-53
lines changed
hypertrace-graphql-labels-schema/src/main/java/org/hypertrace/graphql/label Expand file tree Collapse file tree 4 files changed +41
-53
lines changed Original file line number Diff line number Diff line change 99
1010public class LabelRequestConverter {
1111 CreateLabelRequest convertCreationRequest (LabelCreateRequest creationRequest ) {
12- LabelData .Builder dataBuilder = LabelData .newBuilder ().setKey (creationRequest .label ().key ());
13- Optional .ofNullable (creationRequest .label ().color ()).ifPresent (dataBuilder ::setColor );
14- Optional .ofNullable (creationRequest .label ().description ())
15- .ifPresent (dataBuilder ::setDescription );
16- return CreateLabelRequest .newBuilder ().setData (dataBuilder .build ()).build ();
12+ return CreateLabelRequest .newBuilder ()
13+ .setData (convertLabelData (creationRequest .label ()))
14+ .build ();
1715 }
1816
1917 UpdateLabelRequest convertUpdateRequest (LabelUpdateRequest updateRequest ) {
20- LabelData .Builder dataBuilder = LabelData .newBuilder ().setKey (updateRequest .label ().key ());
21- Optional .ofNullable (updateRequest .label ().color ()).ifPresent (dataBuilder ::setColor );
22- Optional .ofNullable (updateRequest .label ().description ()).ifPresent (dataBuilder ::setDescription );
2318 return UpdateLabelRequest .newBuilder ()
2419 .setId (updateRequest .label ().id ())
25- .setData (dataBuilder . build ( ))
20+ .setData (convertLabelData ( updateRequest . label () ))
2621 .build ();
2722 }
23+
24+ private LabelData convertLabelData (org .hypertrace .graphql .label .schema .LabelData data ) {
25+ LabelData .Builder dataBuilder = LabelData .newBuilder ().setKey (data .key ());
26+ Optional .ofNullable (data .color ()).ifPresent (dataBuilder ::setColor );
27+ Optional .ofNullable (data .description ()).ifPresent (dataBuilder ::setDescription );
28+ return dataBuilder .build ();
29+ }
2830}
Original file line number Diff line number Diff line change 11package org .hypertrace .graphql .label .schema ;
22
3- import graphql .annotations .annotationTypes .GraphQLField ;
43import graphql .annotations .annotationTypes .GraphQLName ;
5- import graphql .annotations .annotationTypes .GraphQLNonNull ;
6- import javax .annotation .Nullable ;
74import org .hypertrace .core .graphql .common .schema .id .Identifiable ;
85
96@ GraphQLName (Label .TYPE_NAME )
10- public interface Label extends Identifiable {
7+ public interface Label extends Identifiable , LabelData {
118 String TYPE_NAME = "Label" ;
129 String ARGUMENT_NAME = "label" ;
13- String KEY = "key" ;
14- String COLOR_KEY = "color" ;
15- String DESCRIPTION_KEY = "description" ;
16-
17- @ GraphQLField
18- @ GraphQLNonNull
19- @ GraphQLName (KEY )
20- String key ();
21-
22- @ GraphQLField
23- @ Nullable
24- @ GraphQLName (COLOR_KEY )
25- String color ();
26-
27- @ GraphQLField
28- @ Nullable
29- @ GraphQLName (DESCRIPTION_KEY )
30- String description ();
3110}
Original file line number Diff line number Diff line change 1+ package org .hypertrace .graphql .label .schema ;
2+
3+ import graphql .annotations .annotationTypes .GraphQLField ;
4+ import graphql .annotations .annotationTypes .GraphQLName ;
5+ import graphql .annotations .annotationTypes .GraphQLNonNull ;
6+ import javax .annotation .Nullable ;
7+
8+ public interface LabelData {
9+ String KEY = "key" ;
10+ String COLOR_KEY = "color" ;
11+ String DESCRIPTION_KEY = "description" ;
12+
13+ @ GraphQLField
14+ @ GraphQLNonNull
15+ @ GraphQLName (KEY )
16+ String key ();
17+
18+ @ GraphQLField
19+ @ Nullable
20+ @ GraphQLName (COLOR_KEY )
21+ String color ();
22+
23+ @ GraphQLField
24+ @ Nullable
25+ @ GraphQLName (DESCRIPTION_KEY )
26+ String description ();
27+ }
Original file line number Diff line number Diff line change 11package org .hypertrace .graphql .label .schema .mutation ;
22
3- import graphql .annotations .annotationTypes .GraphQLField ;
43import graphql .annotations .annotationTypes .GraphQLName ;
5- import graphql .annotations .annotationTypes .GraphQLNonNull ;
6- import javax .annotation .Nullable ;
4+ import org .hypertrace .graphql .label .schema .LabelData ;
75
86@ GraphQLName (CreateLabel .TYPE_NAME )
9- public interface CreateLabel {
7+ public interface CreateLabel extends LabelData {
108 String TYPE_NAME = "CreateLabel" ;
119 String ARGUMENT_NAME = "label" ;
12- String KEY = "key" ;
13- String COLOR_KEY = "color" ;
14- String DESCRIPTION_KEY = "description" ;
15-
16- @ GraphQLField
17- @ GraphQLNonNull
18- @ GraphQLName (KEY )
19- String key ();
20-
21- @ GraphQLField
22- @ Nullable
23- @ GraphQLName (COLOR_KEY )
24- String color ();
25-
26- @ GraphQLField
27- @ Nullable
28- @ GraphQLName (DESCRIPTION_KEY )
29- String description ();
3010}
You can’t perform that action at this time.
0 commit comments