This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Query { | |
| character(id: ID): Character | |
| characters: [Character!]! | |
| } | |
| type Mutation { | |
| createCharacter(input: CreateCharacterRequest): Character | |
| } | |
| type Character { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // import "github.com/google/uuid" | |
| type Server struct { | |
| Characters []*Character | |
| } | |
| type Character struct { | |
| Id string | |
| Name string | |
| Type Type |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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 | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func RegisterEnum(schema *schemabuilder.Schema) { | |
| schema.Enum(Type(0), map[string]interface{}{ | |
| "WIZARD": Type(0), | |
| "MUGGLE": Type(1), | |
| "GOBLIN": Type(2), | |
| "HOUSE_ELF": Type(3), | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (s *Server) RegisterOperations(schema *schemabuilder.Schema) { | |
| schema.Query().FieldFunc("character", func(ctx context.Context, args struct { | |
| Id *schemabuilder.ID | |
| }) *Character { | |
| return s.GetCharacter(ctx, args.Id.Value) | |
| }) | |
| schema.Query().FieldFunc("characters", func(ctx context.Context, args struct{}) []*Character { | |
| return s.ListCharacters(ctx) | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // import "go.appointy.com/jaal" | |
| // import "go.appointy.com/jaal/introspection" | |
| // import "github.com/google/uuid" | |
| func main() { | |
| s := &Server{ | |
| Characters: []*Character{{ | |
| Id: uuid.New().String(), | |
| Name: "Harry Potter", | |
| Type: WIZARD, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "context" | |
| "log" | |
| "net/http" | |
| "go.appointy.com/jaal" | |
| "go.appointy.com/jaal/introspection" | |
| "go.appointy.com/jaal/schemabuilder" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Broomstick { | |
| id: ID! | |
| name: String! | |
| owner: String! | |
| } | |
| input BroomstickInput { | |
| id: ID | |
| name: String | |
| owner: String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // import "github.com/google/uuid" | |
| type Wand struct { | |
| Id string | |
| Length string | |
| Core string | |
| Wood string | |
| } | |
| type Broomstick struct { |
OlderNewer