redo type naming
This commit is contained in:
+14
-14
@@ -9,28 +9,28 @@ import (
|
||||
)
|
||||
|
||||
type InputObjectQueryResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *InputObjectQueryUser `json:"user"`
|
||||
}
|
||||
|
||||
type Role string
|
||||
|
||||
const (
|
||||
StudentRole Role = "STUDENT"
|
||||
TeacherRole Role = "TEACHER"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
type InputObjectQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
type UserQueryInput struct {
|
||||
Email *string `json:"email"`
|
||||
Name *string `json:"name"`
|
||||
Id *string `json:"id"`
|
||||
Role *Role `json:"role"`
|
||||
Names []*string `json:"names"`
|
||||
Email *string `json:"email"`
|
||||
Name *string `json:"name"`
|
||||
Id *string `json:"id"`
|
||||
Role *UserQueryInputRole `json:"role"`
|
||||
Names []*string `json:"names"`
|
||||
}
|
||||
|
||||
type UserQueryInputRole string
|
||||
|
||||
const (
|
||||
UserQueryInputRoleStudent UserQueryInputRole = "STUDENT"
|
||||
UserQueryInputRoleTeacher UserQueryInputRole = "TEACHER"
|
||||
)
|
||||
|
||||
func InputObjectQuery(client *graphql.Client, query *UserQueryInput) (*InputObjectQueryResponse, error) {
|
||||
variables := map[string]interface{}{
|
||||
"query": query,
|
||||
|
||||
+39
-25
@@ -8,35 +8,24 @@ import (
|
||||
"github.com/Khan/genql/graphql"
|
||||
)
|
||||
|
||||
type Article struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v Article) implementsGraphQLInterfaceContent() {}
|
||||
|
||||
type Content interface {
|
||||
implementsGraphQLInterfaceContent()
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryResponse struct {
|
||||
Root Topic `json:"root"`
|
||||
Root InterfaceNoFragmentsQueryRootTopic `json:"root"`
|
||||
}
|
||||
|
||||
type Topic struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []Content `json:"-"`
|
||||
type InterfaceNoFragmentsQueryRootTopic struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Children []InterfaceNoFragmentsQueryRootTopicChildrenContent `json:"-"`
|
||||
}
|
||||
|
||||
func (v *Topic) UnmarshalJSON(b []byte) error {
|
||||
func (v *InterfaceNoFragmentsQueryRootTopic) UnmarshalJSON(b []byte) error {
|
||||
var firstPass struct {
|
||||
*Topic
|
||||
*InterfaceNoFragmentsQueryRootTopic
|
||||
Children json.RawMessage `json:"children"`
|
||||
}
|
||||
firstPass.Topic = v
|
||||
firstPass.InterfaceNoFragmentsQueryRootTopic = v
|
||||
|
||||
err := json.Unmarshal(b, &typenames)
|
||||
err := json.Unmarshal(b, &firstPass)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -51,17 +40,20 @@ func (v *Topic) UnmarshalJSON(b []byte) error {
|
||||
switch tn.TypeName {
|
||||
|
||||
case "Article":
|
||||
v.Children = Article{}
|
||||
|
||||
v.Children = InterfaceNoFragmentsQueryRootTopicChildrenArticle{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.Children, &v.Children)
|
||||
|
||||
case "Video":
|
||||
v.Children = Video{}
|
||||
|
||||
v.Children = InterfaceNoFragmentsQueryRootTopicChildrenVideo{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.Children, &v.Children)
|
||||
|
||||
case "Topic":
|
||||
v.Children = Topic{}
|
||||
|
||||
v.Children = InterfaceNoFragmentsQueryRootTopicChildrenTopic{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.Children, &v.Children)
|
||||
|
||||
@@ -70,14 +62,36 @@ func (v *Topic) UnmarshalJSON(b []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Video struct {
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenArticle struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v Video) implementsGraphQLInterfaceContent() {}
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenArticle) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenContent interface {
|
||||
implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent()
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenTopic struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenTopic) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
type InterfaceNoFragmentsQueryRootTopicChildrenVideo struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
func (v InterfaceNoFragmentsQueryRootTopicChildrenVideo) implementsGraphQLInterfaceInterfaceNoFragmentsQueryRootTopicChildrenContent() {
|
||||
}
|
||||
|
||||
func InterfaceNoFragmentsQuery(client *graphql.Client) (*InterfaceNoFragmentsQueryResponse, error) {
|
||||
var retval InterfaceNoFragmentsQueryResponse
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
type ListInputQueryResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *ListInputQueryUser `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
type ListInputQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
type QueryWithAliasResponse struct {
|
||||
User *User
|
||||
User *QueryWithAliasUser
|
||||
}
|
||||
|
||||
type User struct {
|
||||
type QueryWithAliasUser struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
type QueryWithDoubleAliasResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *QueryWithDoubleAliasUser `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
type QueryWithDoubleAliasUser struct {
|
||||
ID string
|
||||
AlsoID string
|
||||
}
|
||||
|
||||
+8
-8
@@ -9,20 +9,20 @@ import (
|
||||
)
|
||||
|
||||
type QueryWithEnumsResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *QueryWithEnumsUser `json:"user"`
|
||||
}
|
||||
|
||||
type Role string
|
||||
type QueryWithEnumsUser struct {
|
||||
Roles []QueryWithEnumsUserRolesRole `json:"roles"`
|
||||
}
|
||||
|
||||
type QueryWithEnumsUserRolesRole string
|
||||
|
||||
const (
|
||||
StudentRole Role = "STUDENT"
|
||||
TeacherRole Role = "TEACHER"
|
||||
QueryWithEnumsUserRolesRoleStudent QueryWithEnumsUserRolesRole = "STUDENT"
|
||||
QueryWithEnumsUserRolesRoleTeacher QueryWithEnumsUserRolesRole = "TEACHER"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Roles []Role `json:"roles"`
|
||||
}
|
||||
|
||||
func QueryWithEnums(client *graphql.Client) (*QueryWithEnumsResponse, error) {
|
||||
var retval QueryWithEnumsResponse
|
||||
err := client.MakeRequest(context.Background(), `
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
type QueryWithSlicesResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *QueryWithSlicesUser `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
type QueryWithSlicesUser struct {
|
||||
Emails []string `json:"emails"`
|
||||
EmailsOrNull []string `json:"emailsOrNull"`
|
||||
EmailsWithNulls []*string `json:"emailsWithNulls"`
|
||||
|
||||
+9
-9
@@ -8,19 +8,19 @@ import (
|
||||
"github.com/Khan/genql/graphql"
|
||||
)
|
||||
|
||||
type AuthMethod struct {
|
||||
type QueryWithStructsResponse struct {
|
||||
User *QueryWithStructsUser `json:"user"`
|
||||
}
|
||||
|
||||
type QueryWithStructsUser struct {
|
||||
AuthMethods []QueryWithStructsUserAuthMethodsAuthMethod `json:"authMethods"`
|
||||
}
|
||||
|
||||
type QueryWithStructsUserAuthMethodsAuthMethod struct {
|
||||
Provider *string `json:"provider"`
|
||||
Email *string `json:"email"`
|
||||
}
|
||||
|
||||
type QueryWithStructsResponse struct {
|
||||
User *User `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
AuthMethods []AuthMethod `json:"authMethods"`
|
||||
}
|
||||
|
||||
func QueryWithStructs(client *graphql.Client) (*QueryWithStructsResponse, error) {
|
||||
var retval QueryWithStructsResponse
|
||||
err := client.MakeRequest(context.Background(), `
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
type SimpleInputQueryResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *SimpleInputQueryUser `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
type SimpleInputQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
type SimpleQueryResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *SimpleQueryUser `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
type SimpleQueryUser struct {
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -9,10 +9,10 @@ import (
|
||||
)
|
||||
|
||||
type TypeNameQueryResponse struct {
|
||||
User *User `json:"user"`
|
||||
User *TypeNameQueryUser `json:"user"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
type TypeNameQueryUser struct {
|
||||
Typename *string `json:"__typename"`
|
||||
Id string `json:"id"`
|
||||
}
|
||||
|
||||
+19
-14
@@ -8,18 +8,26 @@ import (
|
||||
"github.com/Khan/genql/graphql"
|
||||
)
|
||||
|
||||
type Article struct {
|
||||
type UnionNoFragmentsQueryRandomLeafArticle struct {
|
||||
Typename *string `json:"__typename"`
|
||||
}
|
||||
|
||||
func (v Article) implementsGraphQLInterfaceLeafContent() {}
|
||||
func (v UnionNoFragmentsQueryRandomLeafArticle) implementsGraphQLInterfaceUnionNoFragmentsQueryRandomLeafLeafContent() {
|
||||
}
|
||||
|
||||
type LeafContent interface {
|
||||
implementsGraphQLInterfaceLeafContent()
|
||||
type UnionNoFragmentsQueryRandomLeafLeafContent interface {
|
||||
implementsGraphQLInterfaceUnionNoFragmentsQueryRandomLeafLeafContent()
|
||||
}
|
||||
|
||||
type UnionNoFragmentsQueryRandomLeafVideo struct {
|
||||
Typename *string `json:"__typename"`
|
||||
}
|
||||
|
||||
func (v UnionNoFragmentsQueryRandomLeafVideo) implementsGraphQLInterfaceUnionNoFragmentsQueryRandomLeafLeafContent() {
|
||||
}
|
||||
|
||||
type UnionNoFragmentsQueryResponse struct {
|
||||
RandomLeaf LeafContent `json:"-"`
|
||||
RandomLeaf UnionNoFragmentsQueryRandomLeafLeafContent `json:"-"`
|
||||
}
|
||||
|
||||
func (v *UnionNoFragmentsQueryResponse) UnmarshalJSON(b []byte) error {
|
||||
@@ -29,7 +37,7 @@ func (v *UnionNoFragmentsQueryResponse) UnmarshalJSON(b []byte) error {
|
||||
}
|
||||
firstPass.UnionNoFragmentsQueryResponse = v
|
||||
|
||||
err := json.Unmarshal(b, &typenames)
|
||||
err := json.Unmarshal(b, &firstPass)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -44,12 +52,14 @@ func (v *UnionNoFragmentsQueryResponse) UnmarshalJSON(b []byte) error {
|
||||
switch tn.TypeName {
|
||||
|
||||
case "Article":
|
||||
v.RandomLeaf = Article{}
|
||||
|
||||
v.RandomLeaf = UnionNoFragmentsQueryRandomLeafArticle{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.RandomLeaf, &v.RandomLeaf)
|
||||
|
||||
case "Video":
|
||||
v.RandomLeaf = Video{}
|
||||
|
||||
v.RandomLeaf = UnionNoFragmentsQueryRandomLeafVideo{}
|
||||
err = json.Unmarshal(
|
||||
firstPass.RandomLeaf, &v.RandomLeaf)
|
||||
|
||||
@@ -58,14 +68,9 @@ func (v *UnionNoFragmentsQueryResponse) UnmarshalJSON(b []byte) error {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
type Video struct {
|
||||
Typename *string `json:"__typename"`
|
||||
}
|
||||
|
||||
func (v Video) implementsGraphQLInterfaceLeafContent() {}
|
||||
|
||||
func UnionNoFragmentsQuery(client *graphql.Client) (*UnionNoFragmentsQueryResponse, error) {
|
||||
var retval UnionNoFragmentsQueryResponse
|
||||
err := client.MakeRequest(context.Background(), `
|
||||
|
||||
+20
-20
@@ -8,31 +8,31 @@ import (
|
||||
"github.com/Khan/genql/graphql"
|
||||
)
|
||||
|
||||
type Role string
|
||||
|
||||
const (
|
||||
StudentRole Role = "STUDENT"
|
||||
TeacherRole Role = "TEACHER"
|
||||
)
|
||||
|
||||
type Role1 string
|
||||
|
||||
const (
|
||||
StudentRole1 Role1 = "STUDENT"
|
||||
TeacherRole1 Role1 = "TEACHER"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
Roles []Role `json:"roles"`
|
||||
type UsesEnumTwiceQueryMeUser struct {
|
||||
Roles []UsesEnumTwiceQueryMeUserRolesRole `json:"roles"`
|
||||
}
|
||||
|
||||
type User1 struct {
|
||||
Roles []Role1 `json:"roles"`
|
||||
type UsesEnumTwiceQueryMeUserRolesRole string
|
||||
|
||||
const (
|
||||
UsesEnumTwiceQueryMeUserRolesRoleStudent UsesEnumTwiceQueryMeUserRolesRole = "STUDENT"
|
||||
UsesEnumTwiceQueryMeUserRolesRoleTeacher UsesEnumTwiceQueryMeUserRolesRole = "TEACHER"
|
||||
)
|
||||
|
||||
type UsesEnumTwiceQueryOtherUser struct {
|
||||
Roles []UsesEnumTwiceQueryOtherUserRolesRole `json:"roles"`
|
||||
}
|
||||
|
||||
type UsesEnumTwiceQueryOtherUserRolesRole string
|
||||
|
||||
const (
|
||||
UsesEnumTwiceQueryOtherUserRolesRoleStudent UsesEnumTwiceQueryOtherUserRolesRole = "STUDENT"
|
||||
UsesEnumTwiceQueryOtherUserRolesRoleTeacher UsesEnumTwiceQueryOtherUserRolesRole = "TEACHER"
|
||||
)
|
||||
|
||||
type UsesEnumTwiceQueryResponse struct {
|
||||
Me *User
|
||||
OtherUser *User1
|
||||
Me *UsesEnumTwiceQueryMeUser
|
||||
OtherUser *UsesEnumTwiceQueryOtherUser
|
||||
}
|
||||
|
||||
func UsesEnumTwiceQuery(client *graphql.Client) (*UsesEnumTwiceQueryResponse, error) {
|
||||
|
||||
Reference in New Issue
Block a user