git.sr.ht/~sircmpwn/gqlgen@v0.0.0-20200522192042-c84d29a1c940/codegen/testserver/models.go (about)

     1  package testserver
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  	"io"
     7  )
     8  
     9  type ForcedResolver struct {
    10  	Field Circle
    11  }
    12  
    13  type ModelMethods struct {
    14  }
    15  
    16  func (m ModelMethods) NoContext() bool {
    17  	return true
    18  }
    19  
    20  func (m ModelMethods) WithContext(_ context.Context) bool {
    21  	return true
    22  }
    23  
    24  type Errors struct{}
    25  
    26  type Error struct {
    27  	ID string
    28  }
    29  
    30  func (Error) ErrorOnRequiredField() (string, error) {
    31  	return "", fmt.Errorf("boom")
    32  }
    33  
    34  func (Error) ErrorOnNonRequiredField() (string, error) {
    35  	return "", fmt.Errorf("boom")
    36  }
    37  
    38  func (Error) NilOnRequiredField() *string {
    39  	return nil
    40  }
    41  
    42  type EmbeddedPointerModel struct {
    43  	*EmbeddedPointer
    44  	ID string
    45  }
    46  
    47  type EmbeddedPointer struct {
    48  	Title string
    49  }
    50  
    51  type MarshalPanic string
    52  
    53  func (m *MarshalPanic) UnmarshalGQL(v interface{}) error {
    54  	panic("BOOM")
    55  }
    56  
    57  func (m MarshalPanic) MarshalGQL(w io.Writer) {
    58  	panic("BOOM")
    59  }
    60  
    61  type Panics struct {
    62  }
    63  
    64  func (p *Panics) FieldFuncMarshal(ctx context.Context, u []MarshalPanic) []MarshalPanic {
    65  	return []MarshalPanic{MarshalPanic("aa"), MarshalPanic("bb")}
    66  }
    67  
    68  type Autobind struct {
    69  	Int   int
    70  	Int32 int32
    71  	Int64 int64
    72  
    73  	IdStr string
    74  	IdInt int
    75  }
    76  
    77  type OverlappingFields struct {
    78  	Foo    int
    79  	NewFoo int
    80  }
    81  
    82  type ObjectDirectivesWithCustomGoModel struct {
    83  	NullableText string // not *string, but schema is `String @toNull` type.
    84  }
    85  
    86  type FallbackToStringEncoding string
    87  
    88  const (
    89  	FallbackToStringEncodingA FallbackToStringEncoding = "A"
    90  	FallbackToStringEncodingB FallbackToStringEncoding = "B"
    91  	FallbackToStringEncodingC FallbackToStringEncoding = "C"
    92  )
    93  
    94  type Primitive int
    95  
    96  func (p Primitive) Squared() int {
    97  	return int(p) * int(p)
    98  }
    99  
   100  type PrimitiveString string
   101  
   102  func (s PrimitiveString) Doubled() string {
   103  	return string(s) + string(s)
   104  }
   105  
   106  type Bytes []byte