Skip to content

Instantly share code, notes, and snippets.

View anujdecoder's full-sized avatar

Anuj A Gupta anujdecoder

  • MindTickle
  • Nagpur
View GitHub Profile
func RegisterInput(schema *schemabuilder.Schema) {
input := schema.InputObject("CreateCharacterRequest", CreateCharacterRequest{})
input.FieldFunc("name", func(target *CreateCharacterRequest, source string) {
target.Name = source
})
input.FieldFunc("type", func(target *CreateCharacterRequest, source Type) {
target.Type = source
})
}
//import "go.appointy.com/jaal/schemabuilder"
func RegisterPayload(schema *schemabuilder.Schema) {
payload := schema.Object("Character", Character{})
payload.FieldFunc("id", func(ctx context.Context, in *Character) *schemabuilder.ID {
return &schemabuilder.ID{Value: in.Id}
})
payload.FieldFunc("name", func(ctx context.Context, in *Character) string {
return in.Name
})
// import "github.com/google/uuid"
type Server struct {
Characters []*Character
}
type Character struct {
Id string
Name string
Type Type
type Query {
character(id: ID): Character
characters: [Character!]!
}
type Mutation {
createCharacter(input: CreateCharacterRequest): Character
}
type Character {