github.com/nathanstitt/genqlient@v0.3.1-0.20211028004951-a2bda3c41ab8/graphql/util.go (about) 1 package graphql 2 3 // Utility types used by the generated code. In general, these are *not* 4 // intended for end-users. 5 6 // NoUnmarshalJSON is intended for the use of genqlient's generated code only. 7 // 8 // It is used to prevent a struct type from inheriting its embed's 9 // UnmarshalJSON method, so if we construct a type: 10 // type T struct { E; NoUnmarshalJSON } 11 // where E has an UnmarshalJSON method, T will not inherit it, per the Go 12 // selector rules: https://golang.org/ref/spec#Selectors. 13 type NoUnmarshalJSON struct{} 14 15 // UnmarshalJSON should never be called; it exists only to prevent a sibling 16 // UnmarshalJSON method from being promoted. 17 func (NoUnmarshalJSON) UnmarshalJSON(b []byte) error { 18 panic("NoUnmarshalJSON.UnmarshalJSON should never be called!") 19 } 20 21 // NoMarshalJSON is intended for the use of genqlient's generated code only. 22 // 23 // It is used to prevent a struct type from inheriting its embed's 24 // MarshalJSON method, so if we construct a type: 25 // type T struct { E; NoMarshalJSON } 26 // where E has an MarshalJSON method, T will not inherit it, per the Go 27 // selector rules: https://golang.org/ref/spec#Selectors. 28 type NoMarshalJSON struct{} 29 30 // MarshalJSON should never be called; it exists only to prevent a sibling 31 // MarshalJSON method from being promoted. 32 func (NoMarshalJSON) MarshalJSON() ([]byte, error) { 33 panic("NoUnmarshalJSON.MarshalJSON should never be called!") 34 }