...

Source file src/github.com/99designs/gqlgen/codegen/testserver/singlefile/models-gen.go

Documentation: github.com/99designs/gqlgen/codegen/testserver/singlefile

     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  	"github.com/99designs/gqlgen/graphql"
    12  )
    13  
    14  type Animal interface {
    15  	IsAnimal()
    16  	GetSpecies() string
    17  	GetSize() *Size
    18  }
    19  
    20  type ContentChild interface {
    21  	IsContentChild()
    22  }
    23  
    24  type Mammalian interface {
    25  	IsAnimal()
    26  	IsMammalian()
    27  	GetSpecies() string
    28  	GetSize() *Size
    29  }
    30  
    31  type TestUnion interface {
    32  	IsTestUnion()
    33  }
    34  
    35  type A struct {
    36  	ID string `json:"id"`
    37  }
    38  
    39  func (A) IsTestUnion() {}
    40  
    41  type AIt struct {
    42  	ID string `json:"id"`
    43  }
    44  
    45  type AbIt struct {
    46  	ID string `json:"id"`
    47  }
    48  
    49  type B struct {
    50  	ID string `json:"id"`
    51  }
    52  
    53  func (B) IsTestUnion() {}
    54  
    55  type Cat struct {
    56  	Species  string `json:"species"`
    57  	Size     *Size  `json:"size"`
    58  	CatBreed string `json:"catBreed"`
    59  }
    60  
    61  func (Cat) IsAnimal()               {}
    62  func (this Cat) GetSpecies() string { return this.Species }
    63  func (this Cat) GetSize() *Size     { return this.Size }
    64  
    65  type CheckIssue896 struct {
    66  	ID *int `json:"id,omitempty"`
    67  }
    68  
    69  type ContentPost struct {
    70  	Foo *string `json:"foo,omitempty"`
    71  }
    72  
    73  func (ContentPost) IsContentChild() {}
    74  
    75  type ContentUser struct {
    76  	Foo *string `json:"foo,omitempty"`
    77  }
    78  
    79  func (ContentUser) IsContentChild() {}
    80  
    81  type Coordinates struct {
    82  	X float64 `json:"x"`
    83  	Y float64 `json:"y"`
    84  }
    85  
    86  type DefaultInput struct {
    87  	FalsyBoolean  *bool `json:"falsyBoolean,omitempty"`
    88  	TruthyBoolean *bool `json:"truthyBoolean,omitempty"`
    89  }
    90  
    91  type DefaultParametersMirror struct {
    92  	FalsyBoolean  *bool `json:"falsyBoolean,omitempty"`
    93  	TruthyBoolean *bool `json:"truthyBoolean,omitempty"`
    94  }
    95  
    96  type DeferModel struct {
    97  	ID     string   `json:"id"`
    98  	Name   string   `json:"name"`
    99  	Values []string `json:"values"`
   100  }
   101  
   102  type Dog struct {
   103  	Species  string `json:"species"`
   104  	Size     *Size  `json:"size"`
   105  	DogBreed string `json:"dogBreed"`
   106  }
   107  
   108  func (Dog) IsAnimal()               {}
   109  func (this Dog) GetSpecies() string { return this.Species }
   110  func (this Dog) GetSize() *Size     { return this.Size }
   111  
   112  type EmbeddedDefaultScalar struct {
   113  	Value *string `json:"value,omitempty"`
   114  }
   115  
   116  type FieldsOrderPayload struct {
   117  	FirstFieldValue *string `json:"firstFieldValue,omitempty"`
   118  }
   119  
   120  type Horse struct {
   121  	Species    string `json:"species"`
   122  	Size       *Size  `json:"size"`
   123  	HorseBreed string `json:"horseBreed"`
   124  }
   125  
   126  func (Horse) IsMammalian()            {}
   127  func (this Horse) GetSpecies() string { return this.Species }
   128  func (this Horse) GetSize() *Size     { return this.Size }
   129  
   130  func (Horse) IsAnimal() {}
   131  
   132  type InnerDirectives struct {
   133  	Message string `json:"message"`
   134  }
   135  
   136  type InnerInput struct {
   137  	ID int `json:"id"`
   138  }
   139  
   140  type InnerObject struct {
   141  	ID int `json:"id"`
   142  }
   143  
   144  type InputDirectives struct {
   145  	Text          string           `json:"text"`
   146  	NullableText  *string          `json:"nullableText,omitempty"`
   147  	Inner         *InnerDirectives `json:"inner"`
   148  	InnerNullable *InnerDirectives `json:"innerNullable,omitempty"`
   149  	ThirdParty    *ThirdParty      `json:"thirdParty,omitempty"`
   150  }
   151  
   152  type InputWithEnumValue struct {
   153  	Enum EnumTest `json:"enum"`
   154  }
   155  
   156  type LoopA struct {
   157  	B *LoopB `json:"b"`
   158  }
   159  
   160  type LoopB struct {
   161  	A *LoopA `json:"a"`
   162  }
   163  
   164  // Since gqlgen defines default implementation for a Map scalar, this tests that the builtin is _not_
   165  // added to the TypeMap
   166  type Map struct {
   167  	ID string `json:"id"`
   168  }
   169  
   170  type Mutation struct {
   171  }
   172  
   173  type NestedInput struct {
   174  	Field Email `json:"field"`
   175  }
   176  
   177  type NestedMapInput struct {
   178  	Map map[string]interface{} `json:"map,omitempty"`
   179  }
   180  
   181  type ObjectDirectives struct {
   182  	Text         string   `json:"text"`
   183  	NullableText *string  `json:"nullableText,omitempty"`
   184  	Order        []string `json:"order"`
   185  }
   186  
   187  type OmittableInput struct {
   188  	ID     graphql.Omittable[*string]     `json:"id,omitempty"`
   189  	Bool   graphql.Omittable[*bool]       `json:"bool,omitempty"`
   190  	Str    graphql.Omittable[*string]     `json:"str,omitempty"`
   191  	Int    graphql.Omittable[*int]        `json:"int,omitempty"`
   192  	Time   graphql.Omittable[*time.Time]  `json:"time,omitempty"`
   193  	Enum   graphql.Omittable[*Status]     `json:"enum,omitempty"`
   194  	Scalar graphql.Omittable[*ThirdParty] `json:"scalar,omitempty"`
   195  	Object graphql.Omittable[*OuterInput] `json:"object,omitempty"`
   196  }
   197  
   198  type OuterInput struct {
   199  	Inner *InnerInput `json:"inner"`
   200  }
   201  
   202  type OuterObject struct {
   203  	Inner *InnerObject `json:"inner"`
   204  }
   205  
   206  type Pet struct {
   207  	ID      int    `json:"id"`
   208  	Friends []*Pet `json:"friends,omitempty"`
   209  }
   210  
   211  type Query struct {
   212  }
   213  
   214  type Size struct {
   215  	Height int `json:"height"`
   216  	Weight int `json:"weight"`
   217  }
   218  
   219  type Slices struct {
   220  	Test1 []*string `json:"test1,omitempty"`
   221  	Test2 []string  `json:"test2,omitempty"`
   222  	Test3 []*string `json:"test3"`
   223  	Test4 []string  `json:"test4"`
   224  }
   225  
   226  type SpecialInput struct {
   227  	Nesting *NestedInput `json:"nesting"`
   228  }
   229  
   230  type Subscription struct {
   231  }
   232  
   233  type User struct {
   234  	ID      int        `json:"id"`
   235  	Friends []*User    `json:"friends"`
   236  	Created time.Time  `json:"created"`
   237  	Updated *time.Time `json:"updated,omitempty"`
   238  	Pets    []*Pet     `json:"pets,omitempty"`
   239  }
   240  
   241  type ValidInput struct {
   242  	Break       string `json:"break"`
   243  	Default     string `json:"default"`
   244  	Func        string `json:"func"`
   245  	Interface   string `json:"interface"`
   246  	Select      string `json:"select"`
   247  	Case        string `json:"case"`
   248  	Defer       string `json:"defer"`
   249  	Go          string `json:"go"`
   250  	Map         string `json:"map"`
   251  	Struct      string `json:"struct"`
   252  	Chan        string `json:"chan"`
   253  	Else        string `json:"else"`
   254  	Goto        string `json:"goto"`
   255  	Package     string `json:"package"`
   256  	Switch      string `json:"switch"`
   257  	Const       string `json:"const"`
   258  	Fallthrough string `json:"fallthrough"`
   259  	If          string `json:"if"`
   260  	Range       string `json:"range"`
   261  	Type        string `json:"type"`
   262  	Continue    string `json:"continue"`
   263  	For         string `json:"for"`
   264  	Import      string `json:"import"`
   265  	Return      string `json:"return"`
   266  	Var         string `json:"var"`
   267  	Underscore  string `json:"_"`
   268  }
   269  
   270  // These things are all valid, but without care generate invalid go code
   271  type ValidType struct {
   272  	DifferentCase      string `json:"differentCase"`
   273  	DifferentCaseOld   string `json:"different_case"`
   274  	ValidInputKeywords bool   `json:"validInputKeywords"`
   275  	ValidArgs          bool   `json:"validArgs"`
   276  }
   277  
   278  type XXIt struct {
   279  	ID string `json:"id"`
   280  }
   281  
   282  type XxIt struct {
   283  	ID string `json:"id"`
   284  }
   285  
   286  type AsdfIt struct {
   287  	ID string `json:"id"`
   288  }
   289  
   290  type IIt struct {
   291  	ID string `json:"id"`
   292  }
   293  
   294  type EnumTest string
   295  
   296  const (
   297  	EnumTestOk EnumTest = "OK"
   298  	EnumTestNg EnumTest = "NG"
   299  )
   300  
   301  var AllEnumTest = []EnumTest{
   302  	EnumTestOk,
   303  	EnumTestNg,
   304  }
   305  
   306  func (e EnumTest) IsValid() bool {
   307  	switch e {
   308  	case EnumTestOk, EnumTestNg:
   309  		return true
   310  	}
   311  	return false
   312  }
   313  
   314  func (e EnumTest) String() string {
   315  	return string(e)
   316  }
   317  
   318  func (e *EnumTest) UnmarshalGQL(v interface{}) error {
   319  	str, ok := v.(string)
   320  	if !ok {
   321  		return fmt.Errorf("enums must be strings")
   322  	}
   323  
   324  	*e = EnumTest(str)
   325  	if !e.IsValid() {
   326  		return fmt.Errorf("%s is not a valid EnumTest", str)
   327  	}
   328  	return nil
   329  }
   330  
   331  func (e EnumTest) MarshalGQL(w io.Writer) {
   332  	fmt.Fprint(w, strconv.Quote(e.String()))
   333  }
   334  
   335  type Status string
   336  
   337  const (
   338  	StatusOk    Status = "OK"
   339  	StatusError Status = "ERROR"
   340  )
   341  
   342  var AllStatus = []Status{
   343  	StatusOk,
   344  	StatusError,
   345  }
   346  
   347  func (e Status) IsValid() bool {
   348  	switch e {
   349  	case StatusOk, StatusError:
   350  		return true
   351  	}
   352  	return false
   353  }
   354  
   355  func (e Status) String() string {
   356  	return string(e)
   357  }
   358  
   359  func (e *Status) UnmarshalGQL(v interface{}) error {
   360  	str, ok := v.(string)
   361  	if !ok {
   362  		return fmt.Errorf("enums must be strings")
   363  	}
   364  
   365  	*e = Status(str)
   366  	if !e.IsValid() {
   367  		return fmt.Errorf("%s is not a valid Status", str)
   368  	}
   369  	return nil
   370  }
   371  
   372  func (e Status) MarshalGQL(w io.Writer) {
   373  	fmt.Fprint(w, strconv.Quote(e.String()))
   374  }
   375  

View as plain text