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" | |
| "github.com/google/uuid" | |
| "log" | |
| "net/http" | |
| "go.appointy.com/jaal" | |
| "go.appointy.com/jaal/introspection" |
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 main() { | |
| s := &Server{ | |
| Wands: []*Wand{}, | |
| Broomsticks: []*Broomstick{}, | |
| Snakes: []*Snake{}, | |
| Spiders: []*Spider{}, | |
| } | |
| sb := schemabuilder.NewSchema() | |
| RegisterWand(sb) |
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 MagicalObject struct { | |
| schemabuilder.Union | |
| *Wand | |
| *Broomstick | |
| } | |
| func (s *Server) RegisterUnion(sb *schemabuilder.Schema) { | |
| sb.Query().FieldFunc("magicalObject", func(ctx context.Context, args struct { | |
| Id schemabuilder.ID | |
| }) *MagicalObject { |
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 MagicalCreature struct { | |
| schemabuilder.Interface | |
| *Spider | |
| *Snake | |
| } | |
| func (s *Server) RegisterInterface(sb *schemabuilder.Schema) { | |
| sb.Query().FieldFunc("magicalCreature", func(ctx context.Context, args struct { | |
| Id schemabuilder.ID | |
| }) *MagicalCreature { |
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 { |
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
| 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
| // 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
| 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
| 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), | |
| }) | |
| } |
NewerOlder