github.com/spread-ai/gqlgen@v0.0.0-20221124102857-a6c8ef538a1d/plugin/modelgen/out/generated.go (about)

     1  // Code generated by github.com/spread-ai/gqlgen, DO NOT EDIT.
     2  
     3  package out
     4  
     5  import (
     6  	"fmt"
     7  	"io"
     8  	"strconv"
     9  )
    10  
    11  type A interface {
    12  	IsA()
    13  	GetA() string
    14  }
    15  
    16  type ArrayOfA interface {
    17  	IsArrayOfA()
    18  	GetTrickyField() []A
    19  	GetTrickyFieldPointer() []A
    20  }
    21  
    22  type B interface {
    23  	IsB()
    24  	GetB() int
    25  }
    26  
    27  type C interface {
    28  	IsA()
    29  	IsC()
    30  	GetA() string
    31  	GetC() bool
    32  }
    33  
    34  type D interface {
    35  	IsA()
    36  	IsB()
    37  	IsD()
    38  	GetA() string
    39  	GetB() int
    40  	GetD() *string
    41  }
    42  
    43  type FooBarer interface {
    44  	IsFooBarer()
    45  	GetName() string
    46  }
    47  
    48  // InterfaceWithDescription is an interface with a description
    49  type InterfaceWithDescription interface {
    50  	IsInterfaceWithDescription()
    51  	GetName() *string
    52  }
    53  
    54  type MissingInterface interface {
    55  	IsMissingInterface()
    56  	GetName() *string
    57  }
    58  
    59  type MissingUnion interface {
    60  	IsMissingUnion()
    61  }
    62  
    63  // UnionWithDescription is an union with a description
    64  type UnionWithDescription interface {
    65  	IsUnionWithDescription()
    66  }
    67  
    68  type CDImplemented struct {
    69  	A string  `json:"a" database:"CDImplementeda"`
    70  	B int     `json:"b" database:"CDImplementedb"`
    71  	C bool    `json:"c" database:"CDImplementedc"`
    72  	D *string `json:"d" database:"CDImplementedd"`
    73  }
    74  
    75  func (CDImplemented) IsC()              {}
    76  func (this CDImplemented) GetA() string { return this.A }
    77  func (this CDImplemented) GetC() bool   { return this.C }
    78  
    79  func (CDImplemented) IsA() {}
    80  
    81  func (CDImplemented) IsD() {}
    82  
    83  func (this CDImplemented) GetB() int     { return this.B }
    84  func (this CDImplemented) GetD() *string { return this.D }
    85  
    86  func (CDImplemented) IsB() {}
    87  
    88  type CyclicalA struct {
    89  	FieldOne   *CyclicalB `json:"field_one" database:"CyclicalAfield_one"`
    90  	FieldTwo   *CyclicalB `json:"field_two" database:"CyclicalAfield_two"`
    91  	FieldThree *CyclicalB `json:"field_three" database:"CyclicalAfield_three"`
    92  	FieldFour  string     `json:"field_four" database:"CyclicalAfield_four"`
    93  }
    94  
    95  type CyclicalB struct {
    96  	FieldOne   *CyclicalA `json:"field_one" database:"CyclicalBfield_one"`
    97  	FieldTwo   *CyclicalA `json:"field_two" database:"CyclicalBfield_two"`
    98  	FieldThree *CyclicalA `json:"field_three" database:"CyclicalBfield_three"`
    99  	FieldFour  *CyclicalA `json:"field_four" database:"CyclicalBfield_four"`
   100  	FieldFive  string     `json:"field_five" database:"CyclicalBfield_five"`
   101  }
   102  
   103  type FieldMutationHook struct {
   104  	Name     *string       `json:"name" anotherTag:"tag" database:"FieldMutationHookname"`
   105  	Enum     *ExistingEnum `json:"enum" yetAnotherTag:"12" database:"FieldMutationHookenum"`
   106  	NoVal    *string       `json:"noVal" yaml:"noVal" repeated:"true" database:"FieldMutationHooknoVal"`
   107  	Repeated *string       `json:"repeated" someTag:"value" repeated:"true" database:"FieldMutationHookrepeated"`
   108  }
   109  
   110  type ImplArrayOfA struct {
   111  	TrickyField        []*CDImplemented `json:"trickyField" database:"ImplArrayOfAtrickyField"`
   112  	TrickyFieldPointer []*CDImplemented `json:"trickyFieldPointer" database:"ImplArrayOfAtrickyFieldPointer"`
   113  }
   114  
   115  func (ImplArrayOfA) IsArrayOfA() {}
   116  func (this ImplArrayOfA) GetTrickyField() []A {
   117  	if this.TrickyField == nil {
   118  		return nil
   119  	}
   120  	interfaceSlice := make([]A, 0, len(this.TrickyField))
   121  	for _, concrete := range this.TrickyField {
   122  		interfaceSlice = append(interfaceSlice, concrete)
   123  	}
   124  	return interfaceSlice
   125  }
   126  func (this ImplArrayOfA) GetTrickyFieldPointer() []A {
   127  	if this.TrickyFieldPointer == nil {
   128  		return nil
   129  	}
   130  	interfaceSlice := make([]A, 0, len(this.TrickyFieldPointer))
   131  	for _, concrete := range this.TrickyFieldPointer {
   132  		interfaceSlice = append(interfaceSlice, concrete)
   133  	}
   134  	return interfaceSlice
   135  }
   136  
   137  type MissingInput struct {
   138  	Name *string      `json:"name" database:"MissingInputname"`
   139  	Enum *MissingEnum `json:"enum" database:"MissingInputenum"`
   140  }
   141  
   142  type MissingTypeNotNull struct {
   143  	Name     string               `json:"name" database:"MissingTypeNotNullname"`
   144  	Enum     MissingEnum          `json:"enum" database:"MissingTypeNotNullenum"`
   145  	Int      MissingInterface     `json:"int" database:"MissingTypeNotNullint"`
   146  	Existing *ExistingType        `json:"existing" database:"MissingTypeNotNullexisting"`
   147  	Missing2 *MissingTypeNullable `json:"missing2" database:"MissingTypeNotNullmissing2"`
   148  }
   149  
   150  func (MissingTypeNotNull) IsMissingInterface()   {}
   151  func (this MissingTypeNotNull) GetName() *string { return &this.Name }
   152  
   153  func (MissingTypeNotNull) IsExistingInterface() {}
   154  
   155  func (MissingTypeNotNull) IsMissingUnion() {}
   156  
   157  func (MissingTypeNotNull) IsExistingUnion() {}
   158  
   159  type MissingTypeNullable struct {
   160  	Name     *string             `json:"name" database:"MissingTypeNullablename"`
   161  	Enum     *MissingEnum        `json:"enum" database:"MissingTypeNullableenum"`
   162  	Int      MissingInterface    `json:"int" database:"MissingTypeNullableint"`
   163  	Existing *ExistingType       `json:"existing" database:"MissingTypeNullableexisting"`
   164  	Missing2 *MissingTypeNotNull `json:"missing2" database:"MissingTypeNullablemissing2"`
   165  }
   166  
   167  func (MissingTypeNullable) IsMissingInterface()   {}
   168  func (this MissingTypeNullable) GetName() *string { return this.Name }
   169  
   170  func (MissingTypeNullable) IsExistingInterface() {}
   171  
   172  func (MissingTypeNullable) IsMissingUnion() {}
   173  
   174  func (MissingTypeNullable) IsExistingUnion() {}
   175  
   176  type NotCyclicalA struct {
   177  	FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"`
   178  	FieldTwo int    `json:"FieldTwo" database:"NotCyclicalAFieldTwo"`
   179  }
   180  
   181  type NotCyclicalB struct {
   182  	FieldOne string        `json:"FieldOne" database:"NotCyclicalBFieldOne"`
   183  	FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"`
   184  }
   185  
   186  type Recursive struct {
   187  	FieldOne   *Recursive `json:"FieldOne" database:"RecursiveFieldOne"`
   188  	FieldTwo   *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"`
   189  	FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"`
   190  	FieldFour  string     `json:"FieldFour" database:"RecursiveFieldFour"`
   191  }
   192  
   193  type RenameFieldTest struct {
   194  	GOODnaME   string `json:"badName" database:"RenameFieldTestbadName"`
   195  	OtherField string `json:"otherField" database:"RenameFieldTestotherField"`
   196  }
   197  
   198  // TypeWithDescription is a type with a description
   199  type TypeWithDescription struct {
   200  	Name *string `json:"name" database:"TypeWithDescriptionname"`
   201  }
   202  
   203  func (TypeWithDescription) IsUnionWithDescription() {}
   204  
   205  type FooBarr struct {
   206  	Name string `json:"name" database:"_Foo_Barrname"`
   207  }
   208  
   209  func (FooBarr) IsFooBarer()          {}
   210  func (this FooBarr) GetName() string { return this.Name }
   211  
   212  // EnumWithDescription is an enum with a description
   213  type EnumWithDescription string
   214  
   215  const (
   216  	EnumWithDescriptionCat EnumWithDescription = "CAT"
   217  	EnumWithDescriptionDog EnumWithDescription = "DOG"
   218  )
   219  
   220  var AllEnumWithDescription = []EnumWithDescription{
   221  	EnumWithDescriptionCat,
   222  	EnumWithDescriptionDog,
   223  }
   224  
   225  func (e EnumWithDescription) IsValid() bool {
   226  	switch e {
   227  	case EnumWithDescriptionCat, EnumWithDescriptionDog:
   228  		return true
   229  	}
   230  	return false
   231  }
   232  
   233  func (e EnumWithDescription) String() string {
   234  	return string(e)
   235  }
   236  
   237  func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error {
   238  	str, ok := v.(string)
   239  	if !ok {
   240  		return fmt.Errorf("enums must be strings")
   241  	}
   242  
   243  	*e = EnumWithDescription(str)
   244  	if !e.IsValid() {
   245  		return fmt.Errorf("%s is not a valid EnumWithDescription", str)
   246  	}
   247  	return nil
   248  }
   249  
   250  func (e EnumWithDescription) MarshalGQL(w io.Writer) {
   251  	fmt.Fprint(w, strconv.Quote(e.String()))
   252  }
   253  
   254  type MissingEnum string
   255  
   256  const (
   257  	MissingEnumHello   MissingEnum = "Hello"
   258  	MissingEnumGoodbye MissingEnum = "Goodbye"
   259  )
   260  
   261  var AllMissingEnum = []MissingEnum{
   262  	MissingEnumHello,
   263  	MissingEnumGoodbye,
   264  }
   265  
   266  func (e MissingEnum) IsValid() bool {
   267  	switch e {
   268  	case MissingEnumHello, MissingEnumGoodbye:
   269  		return true
   270  	}
   271  	return false
   272  }
   273  
   274  func (e MissingEnum) String() string {
   275  	return string(e)
   276  }
   277  
   278  func (e *MissingEnum) UnmarshalGQL(v interface{}) error {
   279  	str, ok := v.(string)
   280  	if !ok {
   281  		return fmt.Errorf("enums must be strings")
   282  	}
   283  
   284  	*e = MissingEnum(str)
   285  	if !e.IsValid() {
   286  		return fmt.Errorf("%s is not a valid MissingEnum", str)
   287  	}
   288  	return nil
   289  }
   290  
   291  func (e MissingEnum) MarshalGQL(w io.Writer) {
   292  	fmt.Fprint(w, strconv.Quote(e.String()))
   293  }