total rewrite to interface handling; not complete but it compiles

This commit is contained in:
Ben Kraft
2020-07-16 13:28:43 -07:00
parent af4a765a32
commit cf7136ca65
33 changed files with 712 additions and 173 deletions
+40 -12
View File
@@ -1,19 +1,47 @@
type Response struct {
User *struct {
Id string `json:"id"`
} `json:"user"`
}
package test
type role string
// Code generated by github.com/Khan/genql, DO NOT EDIT.
const (
studentRole role = "STUDENT"
teacherRole role = "TEACHER"
import (
"context"
"github.com/Khan/genql/graphql"
)
type userQueryInput struct {
type QueryWithInputResponse struct {
User *User `json:"user"`
}
type Role string
const (
StudentRole Role = "STUDENT"
TeacherRole Role = "TEACHER"
)
type User struct {
Id string `json:"id"`
}
type UserQueryInput struct {
Email *string `json:"email"`
Name *string `json:"name"`
Id *string `json:"id"`
Role *role `json:"role"`
}
Role *Role `json:"role"`
}
func QueryWithInput(client *graphql.Client, query *UserQueryInput) (*QueryWithInputResponse, error) {
variables := map[string]interface{}{
"query": query,
}
var retval QueryWithInputResponse
err := client.MakeRequest(context.Background(), `
query QueryWithInput ($query: UserQueryInput) {
user(query: $query) {
id
}
}
`, &retval, variables)
return &retval, err
}