|
|
@@ -1,13 +1,24 @@
|
|
|
-module Types
|
|
|
- class QueryType < Types::BaseObject
|
|
|
- # Add root-level fields here.
|
|
|
- # They will be entry points for queries on your schema.
|
|
|
-
|
|
|
- # TODO: remove me
|
|
|
- field :test_field, String, null: false,
|
|
|
- description: "An example field added by the generator"
|
|
|
- def test_field
|
|
|
- "Hello World!"
|
|
|
- end
|
|
|
+# frozen_string_literal: true
|
|
|
+
|
|
|
+class Types::QueryType < Types::BaseObject
|
|
|
+ description 'The root of this schema'
|
|
|
+
|
|
|
+ field :pokemon, Types::PokemonType, null: true do
|
|
|
+ description 'Find a pokemon by ID'
|
|
|
+ argument :id, ID, required: false
|
|
|
+ argument :pokedex_number, Int, required: false
|
|
|
+ end
|
|
|
+
|
|
|
+ field :pokemons, [Types::PokemonType], null: true do
|
|
|
+ description 'Find a pokemon by ID'
|
|
|
+ argument :pokedex_number, Int, required: false
|
|
|
+ end
|
|
|
+
|
|
|
+ def pokemon(args)
|
|
|
+ Pokemon.find_by(args)
|
|
|
+ end
|
|
|
+
|
|
|
+ def pokemons(args = {})
|
|
|
+ Pokemon.where(args)
|
|
|
end
|
|
|
end
|