@@ -70,25 +70,6 @@ func getMapValueString(m map[string]interface{}, key string) string {
70
70
}
71
71
return ""
72
72
}
73
- func getDescription (raw interface {}) string {
74
- var desc string
75
-
76
- switch node := raw .(type ) {
77
- case ast.DescribableNode :
78
- if sval := node .GetDescription (); sval != nil {
79
- desc = sval .Value
80
- }
81
- case map [string ]interface {}:
82
- desc = getMapValueString (node , "Description.Value" )
83
- }
84
- if desc != "" {
85
- if strings .ContainsRune (desc , '\n' ) {
86
-
87
- }
88
- desc = fmt .Sprintf (`"""%s"""` , desc )
89
- }
90
- return desc
91
- }
92
73
93
74
func toSliceString (slice interface {}) []string {
94
75
if slice == nil {
@@ -525,9 +506,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
525
506
fmt .Sprintf ("%v" , node .Name ),
526
507
join (directives , " " ),
527
508
}, " " )
528
- if desc := getDescription (node ); desc != "" {
529
- str = join ([]string {desc , str }, "\n " )
530
- }
531
509
return visitor .ActionUpdate , str
532
510
case map [string ]interface {}:
533
511
name := getMapValueString (node , "Name" )
@@ -540,9 +518,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
540
518
name ,
541
519
join (directives , " " ),
542
520
}, " " )
543
- if desc := getDescription (node ); desc != "" {
544
- str = join ([]string {desc , str }, "\n " )
545
- }
546
521
return visitor .ActionUpdate , str
547
522
}
548
523
return visitor .ActionNoChange , nil
@@ -564,9 +539,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
564
539
join (directives , " " ),
565
540
block (fields ),
566
541
}, " " )
567
- if desc := getDescription (node ); desc != "" {
568
- str = join ([]string {desc , str }, "\n " )
569
- }
570
542
return visitor .ActionUpdate , str
571
543
case map [string ]interface {}:
572
544
name := getMapValueString (node , "Name" )
@@ -583,9 +555,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
583
555
join (directives , " " ),
584
556
block (fields ),
585
557
}, " " )
586
- if desc := getDescription (node ); desc != "" {
587
- str = join ([]string {desc , str }, "\n " )
588
- }
589
558
return visitor .ActionUpdate , str
590
559
}
591
560
return visitor .ActionNoChange , nil
@@ -601,9 +570,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
601
570
directives = append (directives , fmt .Sprintf ("%v" , directive .Name ))
602
571
}
603
572
str := name + wrap ("(" , join (args , ", " ), ")" ) + ": " + ttype + wrap (" " , join (directives , " " ), "" )
604
- if desc := getDescription (node ); desc != "" {
605
- str = join ([]string {desc , str }, "\n " )
606
- }
607
573
return visitor .ActionUpdate , str
608
574
case map [string ]interface {}:
609
575
name := getMapValueString (node , "Name" )
@@ -614,9 +580,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
614
580
directives = append (directives , fmt .Sprintf ("%v" , directive ))
615
581
}
616
582
str := name + wrap ("(" , join (args , ", " ), ")" ) + ": " + ttype + wrap (" " , join (directives , " " ), "" )
617
- if desc := getDescription (node ); desc != "" {
618
- str = join ([]string {desc , str }, "\n " )
619
- }
620
583
return visitor .ActionUpdate , str
621
584
}
622
585
return visitor .ActionNoChange , nil
@@ -636,9 +599,7 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
636
599
wrap ("= " , defaultValue , "" ),
637
600
join (directives , " " ),
638
601
}, " " )
639
- if desc := getDescription (node ); desc != "" {
640
- str = join ([]string {desc , str }, " " )
641
- }
602
+
642
603
return visitor .ActionUpdate , str
643
604
case map [string ]interface {}:
644
605
name := getMapValueString (node , "Name" )
@@ -653,9 +614,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
653
614
wrap ("= " , defaultValue , "" ),
654
615
join (directives , " " ),
655
616
}, " " )
656
- if desc := getDescription (node ); desc != "" {
657
- str = join ([]string {desc , str }, " " )
658
- }
659
617
return visitor .ActionUpdate , str
660
618
}
661
619
return visitor .ActionNoChange , nil
@@ -675,9 +633,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
675
633
join (directives , " " ),
676
634
block (fields ),
677
635
}, " " )
678
- if desc := getDescription (node ); desc != "" {
679
- str = join ([]string {desc , str }, "\n " )
680
- }
681
636
return visitor .ActionUpdate , str
682
637
case map [string ]interface {}:
683
638
name := getMapValueString (node , "Name" )
@@ -692,9 +647,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
692
647
join (directives , " " ),
693
648
block (fields ),
694
649
}, " " )
695
- if desc := getDescription (node ); desc != "" {
696
- str = join ([]string {desc , str }, "\n " )
697
- }
698
650
return visitor .ActionUpdate , str
699
651
}
700
652
return visitor .ActionNoChange , nil
@@ -714,9 +666,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
714
666
join (directives , " " ),
715
667
"= " + join (types , " | " ),
716
668
}, " " )
717
- if desc := getDescription (node ); desc != "" {
718
- str = join ([]string {desc , str }, "\n " )
719
- }
720
669
return visitor .ActionUpdate , str
721
670
case map [string ]interface {}:
722
671
name := getMapValueString (node , "Name" )
@@ -731,9 +680,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
731
680
join (directives , " " ),
732
681
"= " + join (types , " | " ),
733
682
}, " " )
734
- if desc := getDescription (node ); desc != "" {
735
- str = join ([]string {desc , str }, "\n " )
736
- }
737
683
return visitor .ActionUpdate , str
738
684
}
739
685
return visitor .ActionNoChange , nil
@@ -753,9 +699,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
753
699
join (directives , " " ),
754
700
block (values ),
755
701
}, " " )
756
- if desc := getDescription (node ); desc != "" {
757
- str = join ([]string {desc , str }, "\n " )
758
- }
759
702
return visitor .ActionUpdate , str
760
703
case map [string ]interface {}:
761
704
name := getMapValueString (node , "Name" )
@@ -770,9 +713,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
770
713
join (directives , " " ),
771
714
block (values ),
772
715
}, " " )
773
- if desc := getDescription (node ); desc != "" {
774
- str = join ([]string {desc , str }, "\n " )
775
- }
776
716
return visitor .ActionUpdate , str
777
717
}
778
718
return visitor .ActionNoChange , nil
@@ -789,9 +729,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
789
729
name ,
790
730
join (directives , " " ),
791
731
}, " " )
792
- if desc := getDescription (node ); desc != "" {
793
- str = join ([]string {desc , str }, "\n " )
794
- }
795
732
return visitor .ActionUpdate , str
796
733
case map [string ]interface {}:
797
734
name := getMapValueString (node , "Name" )
@@ -803,9 +740,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
803
740
name ,
804
741
join (directives , " " ),
805
742
}, " " )
806
- if desc := getDescription (node ); desc != "" {
807
- str = join ([]string {desc , str }, "\n " )
808
- }
809
743
return visitor .ActionUpdate , str
810
744
}
811
745
return visitor .ActionNoChange , nil
@@ -825,9 +759,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
825
759
join (directives , " " ),
826
760
block (fields ),
827
761
}, " " )
828
- if desc := getDescription (node ); desc != "" {
829
- str = join ([]string {desc , str }, "\n " )
830
- }
831
762
return visitor .ActionUpdate , str
832
763
case map [string ]interface {}:
833
764
name := getMapValueString (node , "Name" )
@@ -842,9 +773,6 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
842
773
join (directives , " " ),
843
774
block (fields ),
844
775
}, " " )
845
- if desc := getDescription (node ); desc != "" {
846
- str = join ([]string {desc , str }, "\n " )
847
- }
848
776
return visitor .ActionUpdate , str
849
777
}
850
778
return visitor .ActionNoChange , nil
@@ -854,16 +782,10 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
854
782
case * ast.TypeExtensionDefinition :
855
783
definition := fmt .Sprintf ("%v" , node .Definition )
856
784
str := "extend " + definition
857
- if desc := getDescription (node ); desc != "" {
858
- str = join ([]string {desc , str }, "\n " )
859
- }
860
785
return visitor .ActionUpdate , str
861
786
case map [string ]interface {}:
862
787
definition := getMapValueString (node , "Definition" )
863
788
str := "extend " + definition
864
- if desc := getDescription (node ); desc != "" {
865
- str = join ([]string {desc , str }, "\n " )
866
- }
867
789
return visitor .ActionUpdate , str
868
790
}
869
791
return visitor .ActionNoChange , nil
@@ -873,19 +795,13 @@ var printDocASTReducer = map[string]visitor.VisitFunc{
873
795
case * ast.DirectiveDefinition :
874
796
args := wrap ("(" , join (toSliceString (node .Arguments ), ", " ), ")" )
875
797
str := fmt .Sprintf ("directive @%v%v on %v" , node .Name , args , join (toSliceString (node .Locations ), " | " ))
876
- if desc := getDescription (node ); desc != "" {
877
- str = join ([]string {desc , str }, "\n " )
878
- }
879
798
return visitor .ActionUpdate , str
880
799
case map [string ]interface {}:
881
800
name := getMapValueString (node , "Name" )
882
801
locations := toSliceString (getMapValue (node , "Locations" ))
883
802
args := toSliceString (getMapValue (node , "Arguments" ))
884
803
argsStr := wrap ("(" , join (args , ", " ), ")" )
885
804
str := fmt .Sprintf ("directive @%v%v on %v" , name , argsStr , join (locations , " | " ))
886
- if desc := getDescription (node ); desc != "" {
887
- str = join ([]string {desc , str }, "\n " )
888
- }
889
805
return visitor .ActionUpdate , str
890
806
}
891
807
return visitor .ActionNoChange , nil
0 commit comments