github.com/senomas/gqlgen@v0.17.11-0.20220626120754-9aee61b0716a/codegen/testserver/singlefile/models-gen.go (about)

     1  // Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
     2  
     3  package singlefile
     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 Coordinates struct {
    68  	X float64 `json:"x"`
    69  	Y float64 `json:"y"`
    70  }
    71  
    72  type DefaultInput struct {
    73  	FalsyBoolean  *bool `json:"falsyBoolean"`
    74  	TruthyBoolean *bool `json:"truthyBoolean"`
    75  }
    76  
    77  type DefaultParametersMirror struct {
    78  	FalsyBoolean  *bool `json:"falsyBoolean"`
    79  	TruthyBoolean *bool `json:"truthyBoolean"`
    80  }
    81  
    82  type Dog struct {
    83  	Species  string `json:"species"`
    84  	DogBreed string `json:"dogBreed"`
    85  }
    86  
    87  func (Dog) IsAnimal() {}
    88  
    89  type EmbeddedDefaultScalar struct {
    90  	Value *string `json:"value"`
    91  }
    92  
    93  type InnerDirectives struct {
    94  	Message string `json:"message"`
    95  }
    96  
    97  type InnerInput struct {
    98  	ID int `json:"id"`
    99  }
   100  
   101  type InnerObject struct {
   102  	ID int `json:"id"`
   103  }
   104  
   105  type InputDirectives struct {
   106  	Text          string           `json:"text"`
   107  	NullableText  *string          `json:"nullableText"`
   108  	Inner         *InnerDirectives `json:"inner"`
   109  	InnerNullable *InnerDirectives `json:"innerNullable"`
   110  	ThirdParty    *ThirdParty      `json:"thirdParty"`
   111  }
   112  
   113  type InputWithEnumValue struct {
   114  	Enum EnumTest `json:"enum"`
   115  }
   116  
   117  type LoopA struct {
   118  	B *LoopB `json:"b"`
   119  }
   120  
   121  type LoopB struct {
   122  	A *LoopA `json:"a"`
   123  }
   124  
   125  // Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_
   126  // added to the TypeMap
   127  type Map struct {
   128  	ID string `json:"id"`
   129  }
   130  
   131  type NestedInput struct {
   132  	Field Email `json:"field"`
   133  }
   134  
   135  type NestedMapInput struct {
   136  	Map map[string]interface{} `json:"map"`
   137  }
   138  
   139  type ObjectDirectives struct {
   140  	Text         string   `json:"text"`
   141  	NullableText *string  `json:"nullableText"`
   142  	Order        []string `json:"order"`
   143  }
   144  
   145  type OuterInput struct {
   146  	Inner *InnerInput `json:"inner"`
   147  }
   148  
   149  type OuterObject struct {
   150  	Inner *InnerObject `json:"inner"`
   151  }
   152  
   153  type Pet struct {
   154  	ID      int    `json:"id"`
   155  	Friends []*Pet `json:"friends"`
   156  }
   157  
   158  type Slices struct {
   159  	Test1 []*string `json:"test1"`
   160  	Test2 []string  `json:"test2"`
   161  	Test3 []*string `json:"test3"`
   162  	Test4 []string  `json:"test4"`
   163  }
   164  
   165  type SpecialInput struct {
   166  	Nesting *NestedInput `json:"nesting"`
   167  }
   168  
   169  type User struct {
   170  	ID      int        `json:"id"`
   171  	Friends []*User    `json:"friends"`
   172  	Created time.Time  `json:"created"`
   173  	Updated *time.Time `json:"updated"`
   174  	Pets    []*Pet     `json:"pets"`
   175  }
   176  
   177  type ValidInput struct {
   178  	Break       string `json:"break"`
   179  	Default     string `json:"default"`
   180  	Func        string `json:"func"`
   181  	Interface   string `json:"interface"`
   182  	Select      string `json:"select"`
   183  	Case        string `json:"case"`
   184  	Defer       string `json:"defer"`
   185  	Go          string `json:"go"`
   186  	Map         string `json:"map"`
   187  	Struct      string `json:"struct"`
   188  	Chan        string `json:"chan"`
   189  	Else        string `json:"else"`
   190  	Goto        string `json:"goto"`
   191  	Package     string `json:"package"`
   192  	Switch      string `json:"switch"`
   193  	Const       string `json:"const"`
   194  	Fallthrough string `json:"fallthrough"`
   195  	If          string `json:"if"`
   196  	Range       string `json:"range"`
   197  	Type        string `json:"type"`
   198  	Continue    string `json:"continue"`
   199  	For         string `json:"for"`
   200  	Import      string `json:"import"`
   201  	Return      string `json:"return"`
   202  	Var         string `json:"var"`
   203  	Underscore  string `json:"_"`
   204  }
   205  
   206  //  These things are all valid, but without care generate invalid go code
   207  type ValidType struct {
   208  	DifferentCase      string `json:"differentCase"`
   209  	DifferentCaseOld   string `json:"different_case"`
   210  	ValidInputKeywords bool   `json:"validInputKeywords"`
   211  	ValidArgs          bool   `json:"validArgs"`
   212  }
   213  
   214  type XXIt struct {
   215  	ID string `json:"id"`
   216  }
   217  
   218  type XxIt struct {
   219  	ID string `json:"id"`
   220  }
   221  
   222  type AsdfIt struct {
   223  	ID string `json:"id"`
   224  }
   225  
   226  type IIt struct {
   227  	ID string `json:"id"`
   228  }
   229  
   230  type EnumTest string
   231  
   232  const (
   233  	EnumTestOk EnumTest = "OK"
   234  	EnumTestNg EnumTest = "NG"
   235  )
   236  
   237  var AllEnumTest = []EnumTest{
   238  	EnumTestOk,
   239  	EnumTestNg,
   240  }
   241  
   242  func (e EnumTest) IsValid() bool {
   243  	switch e {
   244  	case EnumTestOk, EnumTestNg:
   245  		return true
   246  	}
   247  	return false
   248  }
   249  
   250  func (e EnumTest) String() string {
   251  	return string(e)
   252  }
   253  
   254  func (e *EnumTest) UnmarshalGQL(v interface{}) error {
   255  	str, ok := v.(string)
   256  	if !ok {
   257  		return fmt.Errorf("enums must be strings")
   258  	}
   259  
   260  	*e = EnumTest(str)
   261  	if !e.IsValid() {
   262  		return fmt.Errorf("%s is not a valid EnumTest", str)
   263  	}
   264  	return nil
   265  }
   266  
   267  func (e EnumTest) MarshalGQL(w io.Writer) {
   268  	fmt.Fprint(w, strconv.Quote(e.String()))
   269  }
   270  
   271  type Status string
   272  
   273  const (
   274  	StatusOk    Status = "OK"
   275  	StatusError Status = "ERROR"
   276  )
   277  
   278  var AllStatus = []Status{
   279  	StatusOk,
   280  	StatusError,
   281  }
   282  
   283  func (e Status) IsValid() bool {
   284  	switch e {
   285  	case StatusOk, StatusError:
   286  		return true
   287  	}
   288  	return false
   289  }
   290  
   291  func (e Status) String() string {
   292  	return string(e)
   293  }
   294  
   295  func (e *Status) UnmarshalGQL(v interface{}) error {
   296  	str, ok := v.(string)
   297  	if !ok {
   298  		return fmt.Errorf("enums must be strings")
   299  	}
   300  
   301  	*e = Status(str)
   302  	if !e.IsValid() {
   303  		return fmt.Errorf("%s is not a valid Status", str)
   304  	}
   305  	return nil
   306  }
   307  
   308  func (e Status) MarshalGQL(w io.Writer) {
   309  	fmt.Fprint(w, strconv.Quote(e.String()))
   310  }