github.com/nathanstitt/genqlient@v0.3.1-0.20211028004951-a2bda3c41ab8/internal/integration/server/gqlgen_models.go (about)

     1  // Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
     2  
     3  package server
     4  
     5  import (
     6  	"fmt"
     7  	"io"
     8  	"strconv"
     9  )
    10  
    11  type Being interface {
    12  	IsBeing()
    13  }
    14  
    15  type Lucky interface {
    16  	IsLucky()
    17  }
    18  
    19  type Animal struct {
    20  	ID      string      `json:"id"`
    21  	Name    string      `json:"name"`
    22  	Species Species     `json:"species"`
    23  	Owner   Being       `json:"owner"`
    24  	Hair    *BeingsHair `json:"hair"`
    25  }
    26  
    27  func (Animal) IsBeing() {}
    28  
    29  type BeingsHair struct {
    30  	HasHair bool `json:"hasHair"`
    31  }
    32  
    33  type Hair struct {
    34  	Color *string `json:"color"`
    35  }
    36  
    37  type User struct {
    38  	ID          string  `json:"id"`
    39  	Name        string  `json:"name"`
    40  	LuckyNumber *int    `json:"luckyNumber"`
    41  	Hair        *Hair   `json:"hair"`
    42  	Birthdate   *string `json:"birthdate"`
    43  	Friends     []*User `json:"friends"`
    44  }
    45  
    46  func (User) IsBeing() {}
    47  func (User) IsLucky() {}
    48  
    49  type Species string
    50  
    51  const (
    52  	SpeciesDog        Species = "DOG"
    53  	SpeciesCoelacanth Species = "COELACANTH"
    54  )
    55  
    56  var AllSpecies = []Species{
    57  	SpeciesDog,
    58  	SpeciesCoelacanth,
    59  }
    60  
    61  func (e Species) IsValid() bool {
    62  	switch e {
    63  	case SpeciesDog, SpeciesCoelacanth:
    64  		return true
    65  	}
    66  	return false
    67  }
    68  
    69  func (e Species) String() string {
    70  	return string(e)
    71  }
    72  
    73  func (e *Species) UnmarshalGQL(v interface{}) error {
    74  	str, ok := v.(string)
    75  	if !ok {
    76  		return fmt.Errorf("enums must be strings")
    77  	}
    78  
    79  	*e = Species(str)
    80  	if !e.IsValid() {
    81  		return fmt.Errorf("%s is not a valid Species", str)
    82  	}
    83  	return nil
    84  }
    85  
    86  func (e Species) MarshalGQL(w io.Writer) {
    87  	fmt.Fprint(w, strconv.Quote(e.String()))
    88  }