()
| 714 | } |
| 715 | |
| 716 | func (t *gqlType) String() string { |
| 717 | if t == nil { |
| 718 | return "" |
| 719 | } |
| 720 | // refer http://spec.graphql.org/June2018/#sec-Type-Kinds |
| 721 | // it confirms, if type kind is LIST or NON_NULL all other fields except ofType will be |
| 722 | // null, so there won't be any name at that level. For other kinds, there will always be a name. |
| 723 | switch t.Kind { |
| 724 | case list: |
| 725 | return fmt.Sprintf("[%s]", t.OfType.String()) |
| 726 | case nonNull: |
| 727 | return fmt.Sprintf("%s!", t.OfType.String()) |
| 728 | // TODO: we will consider ID as String for the purpose of type matching |
| 729 | //case "SCALAR": |
| 730 | // if t.Name == "ID" { |
| 731 | // return "String" |
| 732 | // } |
| 733 | // return t.Name |
| 734 | default: |
| 735 | return t.Name |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | func (t *gqlType) NamedType() string { |
| 740 | if t.Name != "" { |
no outgoing calls