git.sr.ht/~sircmpwn/gqlgen@v0.0.0-20200522192042-c84d29a1c940/codegen/testserver/models-gen.go (about)

     1  // Code generated by git.sr.ht/~sircmpwn/gqlgen, DO NOT EDIT.
     2  
     3  package testserver
     4  
     5  import (
     6  	"fmt"
     7  	"io"
     8  	"strconv"
     9  	"time"
    10  )
    11  
    12  type Animal interface {
    13  	IsAnimal()
    14  }
    15  
    16  type ContentChild interface {
    17  	IsContentChild()
    18  }
    19  
    20  type TestUnion interface {
    21  	IsTestUnion()
    22  }
    23  
    24  type A struct {
    25  	ID string `json:"id"`
    26  }
    27  
    28  func (A) IsTestUnion() {}
    29  
    30  type AIt struct {
    31  	ID string `json:"id"`
    32  }
    33  
    34  type AbIt struct {
    35  	ID string `json:"id"`
    36  }
    37  
    38  type B struct {
    39  	ID string `json:"id"`
    40  }
    41  
    42  func (B) IsTestUnion() {}
    43  
    44  type Cat struct {
    45  	Species  string `json:"species"`
    46  	CatBreed string `json:"catBreed"`
    47  }
    48  
    49  func (Cat) IsAnimal() {}
    50  
    51  type CheckIssue896 struct {
    52  	ID *int `json:"id"`
    53  }
    54  
    55  type ContentPost struct {
    56  	Foo *string `json:"foo"`
    57  }
    58  
    59  func (ContentPost) IsContentChild() {}
    60  
    61  type ContentUser struct {
    62  	Foo *string `json:"foo"`
    63  }
    64  
    65  func (ContentUser) IsContentChild() {}
    66  
    67  type Dog struct {
    68  	Species  string `json:"species"`
    69  	DogBreed string `json:"dogBreed"`
    70  }
    71  
    72  func (Dog) IsAnimal() {}
    73  
    74  type EmbeddedDefaultScalar struct {
    75  	Value *string `json:"value"`
    76  }
    77  
    78  type InnerDirectives struct {
    79  	Message string `json:"message"`
    80  }
    81  
    82  type InnerInput struct {
    83  	ID int `json:"id"`
    84  }
    85  
    86  type InnerObject struct {
    87  	ID int `json:"id"`
    88  }
    89  
    90  type InputDirectives struct {
    91  	Text          string           `json:"text"`
    92  	NullableText  *string          `json:"nullableText"`
    93  	Inner         *InnerDirectives `json:"inner"`
    94  	InnerNullable *InnerDirectives `json:"innerNullable"`
    95  	ThirdParty    *ThirdParty      `json:"thirdParty"`
    96  }
    97  
    98  type InputWithEnumValue struct {
    99  	Enum EnumTest `json:"enum"`
   100  }
   101  
   102  type LoopA struct {
   103  	B *LoopB `json:"b"`
   104  }
   105  
   106  type LoopB struct {
   107  	A *LoopA `json:"a"`
   108  }
   109  
   110  // Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_
   111  // added to the TypeMap
   112  type Map struct {
   113  	ID string `json:"id"`
   114  }
   115  
   116  type NestedMapInput struct {
   117  	Map map[string]interface{} `json:"map"`
   118  }
   119  
   120  type ObjectDirectives struct {
   121  	Text         string  `json:"text"`
   122  	NullableText *string `json:"nullableText"`
   123  }
   124  
   125  type OuterInput struct {
   126  	Inner *InnerInput `json:"inner"`
   127  }
   128  
   129  type OuterObject struct {
   130  	Inner *InnerObject `json:"inner"`
   131  }
   132  
   133  type Slices struct {
   134  	Test1 []*string `json:"test1"`
   135  	Test2 []string  `json:"test2"`
   136  	Test3 []*string `json:"test3"`
   137  	Test4 []string  `json:"test4"`
   138  }
   139  
   140  type User struct {
   141  	ID      int        `json:"id"`
   142  	Friends []*User    `json:"friends"`
   143  	Created time.Time  `json:"created"`
   144  	Updated *time.Time `json:"updated"`
   145  }
   146  
   147  type ValidInput struct {
   148  	Break       string `json:"break"`
   149  	Default     string `json:"default"`
   150  	Func        string `json:"func"`
   151  	Interface   string `json:"interface"`
   152  	Select      string `json:"select"`
   153  	Case        string `json:"case"`
   154  	Defer       string `json:"defer"`
   155  	Go          string `json:"go"`
   156  	Map         string `json:"map"`
   157  	Struct      string `json:"struct"`
   158  	Chan        string `json:"chan"`
   159  	Else        string `json:"else"`
   160  	Goto        string `json:"goto"`
   161  	Package     string `json:"package"`
   162  	Switch      string `json:"switch"`
   163  	Const       string `json:"const"`
   164  	Fallthrough string `json:"fallthrough"`
   165  	If          string `json:"if"`
   166  	Range       string `json:"range"`
   167  	Type        string `json:"type"`
   168  	Continue    string `json:"continue"`
   169  	For         string `json:"for"`
   170  	Import      string `json:"import"`
   171  	Return      string `json:"return"`
   172  	Var         string `json:"var"`
   173  	Underscore  string `json:"_"`
   174  }
   175  
   176  //  These things are all valid, but without care generate invalid go code
   177  type ValidType struct {
   178  	DifferentCase      string `json:"differentCase"`
   179  	DifferentCaseOld   string `json:"different_case"`
   180  	ValidInputKeywords bool   `json:"validInputKeywords"`
   181  	ValidArgs          bool   `json:"validArgs"`
   182  }
   183  
   184  type XXIt struct {
   185  	ID string `json:"id"`
   186  }
   187  
   188  type XxIt struct {
   189  	ID string `json:"id"`
   190  }
   191  
   192  type AsdfIt struct {
   193  	ID string `json:"id"`
   194  }
   195  
   196  type IIt struct {
   197  	ID string `json:"id"`
   198  }
   199  
   200  type EnumTest string
   201  
   202  const (
   203  	EnumTestOk EnumTest = "OK"
   204  	EnumTestNg EnumTest = "NG"
   205  )
   206  
   207  var AllEnumTest = []EnumTest{
   208  	EnumTestOk,
   209  	EnumTestNg,
   210  }
   211  
   212  func (e EnumTest) IsValid() bool {
   213  	switch e {
   214  	case EnumTestOk, EnumTestNg:
   215  		return true
   216  	}
   217  	return false
   218  }
   219  
   220  func (e EnumTest) String() string {
   221  	return string(e)
   222  }
   223  
   224  func (e *EnumTest) UnmarshalGQL(v interface{}) error {
   225  	str, ok := v.(string)
   226  	if !ok {
   227  		return fmt.Errorf("enums must be strings")
   228  	}
   229  
   230  	*e = EnumTest(str)
   231  	if !e.IsValid() {
   232  		return fmt.Errorf("%s is not a valid EnumTest", str)
   233  	}
   234  	return nil
   235  }
   236  
   237  func (e EnumTest) MarshalGQL(w io.Writer) {
   238  	fmt.Fprint(w, strconv.Quote(e.String()))
   239  }
   240  
   241  type Status string
   242  
   243  const (
   244  	StatusOk    Status = "OK"
   245  	StatusError Status = "ERROR"
   246  )
   247  
   248  var AllStatus = []Status{
   249  	StatusOk,
   250  	StatusError,
   251  }
   252  
   253  func (e Status) IsValid() bool {
   254  	switch e {
   255  	case StatusOk, StatusError:
   256  		return true
   257  	}
   258  	return false
   259  }
   260  
   261  func (e Status) String() string {
   262  	return string(e)
   263  }
   264  
   265  func (e *Status) UnmarshalGQL(v interface{}) error {
   266  	str, ok := v.(string)
   267  	if !ok {
   268  		return fmt.Errorf("enums must be strings")
   269  	}
   270  
   271  	*e = Status(str)
   272  	if !e.IsValid() {
   273  		return fmt.Errorf("%s is not a valid Status", str)
   274  	}
   275  	return nil
   276  }
   277  
   278  func (e Status) MarshalGQL(w io.Writer) {
   279  	fmt.Fprint(w, strconv.Quote(e.String()))
   280  }