github.com/geneva/gqlgen@v0.17.7-0.20230801155730-7b9317164836/plugin/modelgen/out/generated.go (about)

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