...

Source file src/github.com/99designs/gqlgen/plugin/modelgen/out/generated.go

Documentation: github.com/99designs/gqlgen/plugin/modelgen/out

     1  // Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
     2  
     3  package out
     4  
     5  import (
     6  	"fmt"
     7  	"io"
     8  	"strconv"
     9  
    10  	"github.com/99designs/gqlgen/graphql"
    11  	"github.com/99designs/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 Mutation struct {
   200  }
   201  
   202  type NotCyclicalA struct {
   203  	FieldOne string `json:"FieldOne" database:"NotCyclicalAFieldOne"`
   204  	FieldTwo int    `json:"FieldTwo" database:"NotCyclicalAFieldTwo"`
   205  }
   206  
   207  type NotCyclicalB struct {
   208  	FieldOne string        `json:"FieldOne" database:"NotCyclicalBFieldOne"`
   209  	FieldTwo *NotCyclicalA `json:"FieldTwo" database:"NotCyclicalBFieldTwo"`
   210  }
   211  
   212  type OmitEmptyJSONTagTest struct {
   213  	ValueNonNil string  `json:"ValueNonNil" database:"OmitEmptyJsonTagTestValueNonNil"`
   214  	Value       *string `json:"Value,omitempty" database:"OmitEmptyJsonTagTestValue"`
   215  }
   216  
   217  type Query struct {
   218  }
   219  
   220  type Recursive struct {
   221  	FieldOne   *Recursive `json:"FieldOne" database:"RecursiveFieldOne"`
   222  	FieldTwo   *Recursive `json:"FieldTwo" database:"RecursiveFieldTwo"`
   223  	FieldThree *Recursive `json:"FieldThree" database:"RecursiveFieldThree"`
   224  	FieldFour  string     `json:"FieldFour" database:"RecursiveFieldFour"`
   225  }
   226  
   227  type RenameFieldTest struct {
   228  	GOODnaME   string `json:"badName" database:"RenameFieldTestbadName"`
   229  	OtherField string `json:"otherField" database:"RenameFieldTestotherField"`
   230  }
   231  
   232  type Subscription struct {
   233  }
   234  
   235  // TypeWithDescription is a type with a description
   236  type TypeWithDescription struct {
   237  	Name *string `json:"name,omitempty" database:"TypeWithDescriptionname"`
   238  }
   239  
   240  func (TypeWithDescription) IsUnionWithDescription() {}
   241  
   242  type Xer struct {
   243  	Id   string `json:"Id" database:"XerId"`
   244  	Name string `json:"Name" database:"XerName"`
   245  }
   246  
   247  func (Xer) IsX()               {}
   248  func (this Xer) GetId() string { return this.Id }
   249  
   250  type FooBarr struct {
   251  	Name string `json:"name" database:"_Foo_Barrname"`
   252  }
   253  
   254  func (FooBarr) IsFooBarer()          {}
   255  func (this FooBarr) GetName() string { return this.Name }
   256  
   257  // EnumWithDescription is an enum with a description
   258  type EnumWithDescription string
   259  
   260  const (
   261  	EnumWithDescriptionCat EnumWithDescription = "CAT"
   262  	EnumWithDescriptionDog EnumWithDescription = "DOG"
   263  )
   264  
   265  var AllEnumWithDescription = []EnumWithDescription{
   266  	EnumWithDescriptionCat,
   267  	EnumWithDescriptionDog,
   268  }
   269  
   270  func (e EnumWithDescription) IsValid() bool {
   271  	switch e {
   272  	case EnumWithDescriptionCat, EnumWithDescriptionDog:
   273  		return true
   274  	}
   275  	return false
   276  }
   277  
   278  func (e EnumWithDescription) String() string {
   279  	return string(e)
   280  }
   281  
   282  func (e *EnumWithDescription) UnmarshalGQL(v interface{}) error {
   283  	str, ok := v.(string)
   284  	if !ok {
   285  		return fmt.Errorf("enums must be strings")
   286  	}
   287  
   288  	*e = EnumWithDescription(str)
   289  	if !e.IsValid() {
   290  		return fmt.Errorf("%s is not a valid EnumWithDescription", str)
   291  	}
   292  	return nil
   293  }
   294  
   295  func (e EnumWithDescription) MarshalGQL(w io.Writer) {
   296  	fmt.Fprint(w, strconv.Quote(e.String()))
   297  }
   298  
   299  type MissingEnum string
   300  
   301  const (
   302  	MissingEnumHello   MissingEnum = "Hello"
   303  	MissingEnumGoodbye MissingEnum = "Goodbye"
   304  )
   305  
   306  var AllMissingEnum = []MissingEnum{
   307  	MissingEnumHello,
   308  	MissingEnumGoodbye,
   309  }
   310  
   311  func (e MissingEnum) IsValid() bool {
   312  	switch e {
   313  	case MissingEnumHello, MissingEnumGoodbye:
   314  		return true
   315  	}
   316  	return false
   317  }
   318  
   319  func (e MissingEnum) String() string {
   320  	return string(e)
   321  }
   322  
   323  func (e *MissingEnum) UnmarshalGQL(v interface{}) error {
   324  	str, ok := v.(string)
   325  	if !ok {
   326  		return fmt.Errorf("enums must be strings")
   327  	}
   328  
   329  	*e = MissingEnum(str)
   330  	if !e.IsValid() {
   331  		return fmt.Errorf("%s is not a valid MissingEnum", str)
   332  	}
   333  	return nil
   334  }
   335  
   336  func (e MissingEnum) MarshalGQL(w io.Writer) {
   337  	fmt.Fprint(w, strconv.Quote(e.String()))
   338  }
   339  

View as plain text