Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions app/models/graph/types/film.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ module Types

global_id_field :id

connection :starships, Graph::Types::Starship.connection_type
connection :vehicles, Graph::Types::Vehicle.connection_type
connection :species, Graph::Types::Species.connection_type
connection :characters, Graph::Types::Person.connection_type
connection :planets, Graph::Types::Planet.connection_type

field :title, types.String, "The title of this film"
field :episodeID, types.Int, "The episode number of this film.", property: :episode_id
field :openingCrawl, types.String,
Expand All @@ -24,12 +30,6 @@ module Types

field :created_at, types.String, "The ISO 8601 date format of the time that this resource was created."
field :updated_at, types.String, "The ISO 8601 date format of the time that this resource was edited."

# TODO field :species
# TODO field :starships
# TODO field :vehicles
# TODO field :characters
# TODO field :planets
end
end
end
4 changes: 4 additions & 0 deletions app/models/graph/types/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ module Types

global_id_field :id

connection :starships, Graph::Types::Starship.connection_type
connection :vehicles, Graph::Types::Vehicle.connection_type
connection :films, Graph::Types::Film.connection_type

field :birthYear, types.String,
"The birth year of the person, using the in-universe standard of BBY or ABY"\
" - Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin"\
Expand Down
3 changes: 3 additions & 0 deletions app/models/graph/types/planet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module Types

global_id_field :id

connection :films, Graph::Types::Film.connection_type
connection :residents, Graph::Types::Person.connection_type

field :name, types.String, "The name of this planet."
field :diameter, types.Int, "The diameter of this planet in kilometers."

Expand Down
3 changes: 3 additions & 0 deletions app/models/graph/types/species.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ module Types

global_id_field :id

connection :people, Graph::Types::Person.connection_type
connection :films, Graph::Types::Film.connection_type

field :name, types.String, "The name of this species."
field :classification, types.String, "The classification of this species, such as \"mammal\" or \"reptile\"."
field :designation, types.String, "The designation of this species, such as \"sentient\"."
Expand Down
2 changes: 1 addition & 1 deletion app/models/graph/types/starship.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module Types
end

field :consumables, types.String, "The maximum length of time that this starship can provide consumables for its entire crew without having to resupply."
field :pilots, types[Graph::Types::Person], "The pilots on this starship."
connection :pilots, Graph::Types::Person.connection_type

field :created_at, types.String, "The ISO 8601 date format of the time that this resource was created."
field :updated_at, types.String, "The ISO 8601 date format of the time that this resource was updated."
Expand Down
2 changes: 1 addition & 1 deletion app/models/graph/types/transport_interface.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module Types
field :maxAtmospheringSpeed, types.Int
field :cargoCapacity, types.Float
field :consumables, types.String
field :pilots, types[Graph::Types::Person]
connection :pilots, Graph::Types::Person.connection_type
end
end
end
2 changes: 1 addition & 1 deletion app/models/graph/types/vehicle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ module Types
end

field :consumables, types.String, "The maximum length of time that this vehicle can provide consumables for its entire crew without having to resupply."
field :pilots, types[Graph::Types::Person], "The pilots on this vehicle."
connection :pilots, Graph::Types::Person.connection_type

field :created_at, types.String, "The ISO 8601 date format of the time that this resource was created."
field :updated_at, types.String, "The ISO 8601 date format of the time that this resource was updated."
Expand Down
10 changes: 10 additions & 0 deletions config/initializers/graphql.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# TODO(xuorig) remove this when
# https://github.com/rmosolgo/graphql-ruby/pull/535 is fixed
module GraphQL
class BaseType
def connection_type
name # lolwat
@connection_type ||= define_connection
end
end
end
18 changes: 0 additions & 18 deletions test/controllers/graphql_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ class GraphQLControllerTest < ActionDispatch::IntegrationTest
"manufacturer" => "Corellian Engineering Corporation",
"maxAtmospheringSpeed" => 1050,
"passengers" => "6",
"pilots" => [
{ "name" => "Chewbacca" },
{ "name" => "Han Solo" },
{ "name" => "Lando Calrissian" },
{ "name" => "Nien Nunb" },
{ "name" => "Chewbacca" },
{ "name" => "Han Solo" },
{ "name" => "Lando Calrissian" },
{ "name" => "Nien Nunb" }
],
"starshipClass" => "Light freighter"
},
"vehicle" => {
Expand All @@ -91,12 +81,6 @@ class GraphQLControllerTest < ActionDispatch::IntegrationTest
"manufacturer" => "Incom corporation",
"maxAtmospheringSpeed" => 650,
"passengers" => "0",
"pilots" => [
{ "name" => "Luke Skywalker" },
{ "name" => "Wedge Antilles" },
{ "name" => "Luke Skywalker" },
{ "name" => "Wedge Antilles" },
],
"vehicleClass"=>"airspeeder"
}
}
Expand Down Expand Up @@ -190,7 +174,6 @@ def full_graphql_query
manufacturer
maxAtmospheringSpeed
passengers
pilots { name }
starshipClass
}
vehicle(id: $vehicleID) {
Expand All @@ -206,7 +189,6 @@ def full_graphql_query
manufacturer
maxAtmospheringSpeed
passengers
pilots { name }
vehicleClass
}
}
Expand Down