Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AttackType = graphql.NewObject(graphql.ObjectConfig{ Name: "Attack", Description: "Represents a Pokémon's attack types", Fields: graphql.Fields{ "name": { Type: graphql.String, Description: "The name of this Pokémon attack", }, "type": { Type: graphql.String, Description: "The type of this Pokémon attack", }, "damage": { Type: graphql.Int, Description: "The damage of this Pokémon attack", }, }, })
View Source
var Pokemon = graphql.NewObject(graphql.ObjectConfig{ Name: "Pokemon", Description: "Represents a Pokémon", Fields: graphql.Fields{ "id": utils.GlobalIdField("Pokemon"), "number": { Type: graphql.String, Description: "The identifier of this Pokémon", Resolve: func(p graphql.ResolveParams) (interface{}, error) { d, ok := p.Source.(models.Pokemon) if !ok { return nil, utils.TypeError(models.Pokemon{}, p.Source) } return d.Id[len(d.Id)-3:], nil }, }, "name": { Type: graphql.String, Description: "The name of this Pokémon", }, "weight": { Type: PokemonDimension, Description: "The minimum and maximum weight of this Pokémon", }, "height": { Type: PokemonDimension, Description: "The minimum and maximum weight of this Pokémon", }, "classification": { Type: graphql.String, Description: "The classification of this Pokémon", }, "types": { Type: graphql.NewList(graphql.String), Description: "The type(s) of this Pokémon", }, "resistant": { Type: graphql.NewList(graphql.String), Description: "The type(s) of Pokémons that this Pokémon is resistant to", }, "attacks": { Type: PokemonAttack, Description: "The attacks of this Pokémon", }, "weaknesses": { Type: graphql.NewList(graphql.String), Description: "The type(s) of Pokémons that this Pokémon weak to", }, "fleeRate": { Type: graphql.Float, }, "maxCP": { Type: graphql.Int, Description: "The maximum CP of this Pokémon", }, "evolutionRequirements": { Type: PokemonEvolutionRequirement, Description: "The evolution requirements of this Pokémon", }, "maxHP": { Type: graphql.Int, Description: "The maximum HP of this Pokémon", }, "image": { Type: graphql.String, Description: "A image of the Pokemon", Resolve: func(p graphql.ResolveParams) (interface{}, error) { d, ok := p.Source.(models.Pokemon) if !ok { return nil, utils.TypeError(models.Pokemon{}, p.Source) } imageName := strings.ToLower(d.Name) imageName = pkmnNameRegex.ReplaceAllString(imageName, "") imageName = strings.ReplaceAll(imageName, " ", "-") return fmt.Sprintf("https://img.pokemondb.net/artwork/%s.jpg", imageName), nil }, }, }, })
View Source
var PokemonAttack = graphql.NewObject(graphql.ObjectConfig{ Name: "PokemonAttack", Description: "Represents a Pokemon's attack types", Fields: graphql.Fields{ "fast": { Type: graphql.NewList(AttackType), Description: "The fast attacks of this pokemon", Resolve: func(p graphql.ResolveParams) (interface{}, error) { d, ok := p.Source.(models.PokemonAttack) if !ok { return nil, utils.TypeError(models.PokemonAttack{}, p.Source) } return d.Fast, nil }, }, "special": { Type: graphql.NewList(AttackType), Description: "The special attacks of this pokemon", Resolve: func(p graphql.ResolveParams) (interface{}, error) { d, ok := p.Source.(models.PokemonAttack) if !ok { return nil, utils.TypeError(models.PokemonAttack{}, p.Source) } return d.Special, nil }, }, }, })
View Source
var PokemonDimension = graphql.NewObject(graphql.ObjectConfig{ Name: "PokemonDimension", Description: "Represents a Pokémon's dimensions", Fields: graphql.Fields{ "minimum": { Type: graphql.String, Description: "The minimum value of this dimension", }, "maximum": { Type: graphql.String, Description: "The maximum value of this dimension", }, }, })
View Source
var PokemonEvolutionRequirement = graphql.NewObject(graphql.ObjectConfig{ Name: "PokemonEvolutionRequirement", Description: "Represents a Pokémon's requirement to evolve", Fields: graphql.Fields{ "amount": { Type: graphql.Int, Description: "The amount of candies to evolve", }, "name": { Type: graphql.String, Description: "The name of the candy to evolve", }, }, })
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.