Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.

Commit b4a9163

Browse files
committed
Revert "Vehicle type and transport interface"
This reverts commit c3d4fc5.
1 parent c3d4fc5 commit b4a9163

6 files changed

Lines changed: 17 additions & 140 deletions

File tree

app/models/graph/schema.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
module Graph
22
Schema = GraphQL::Schema.define do
33
query Graph::Types::Query
4-
resolve_type ->(obj, ctx) do
5-
MySchema.types.values.find { |type| type.name == obj.class.name }
6-
end
74
end
85
end

app/models/graph/types/query.rb

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,6 @@ module Types
4848
field :starships, types[Graph::Types::Starship] do
4949
resolve ->(_, _, _) { ::Starship.all }
5050
end
51-
52-
field :vehicle, Graph::Types::Vehicle do
53-
argument :id, types.ID
54-
resolve ->(_, args, _) { ::Vehicle.find(args['id']) }
55-
end
56-
57-
field :vehicles, types[Graph::Types::Vehicle] do
58-
resolve ->(_, _, _) { ::Vehicle.all }
59-
end
6051
end
6152
end
6253
end

app/models/graph/types/starship.rb

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,28 @@ module Types
44
name "Starship"
55
description "A single transport craft that has hyperdrive capability."
66

7-
interfaces [Graph::Types::TransportInterface]
7+
field :id, types.ID, "The ID of this species."
88

9-
field :id, types.ID, "The ID of this starship."
10-
11-
# Starship Specific Fields
9+
field :name, types.String, "The name of this starship. The common name, such as \"Death Star\"."
10+
field :model, types.String, "The model or official name of this starship. Such as \"T-65 X-wing\" or \"DS-1 Orbital Battle Station\"."
1211

1312
field :starshipClass, types.String do
1413
description "The class of this starship, such as \"Starfighter\" or \"Deep Space Mobile Battlestation\""
1514
property :starship_class
1615
end
1716

17+
field :manufacturer, types.String, "The manufacturer of this starship."
18+
field :costInCredits, types.Float, "The cost of this starship new, in galactic credits", property: :cost_in_credits
19+
field :length, types.Float, "The length of this starship in meters."
20+
field :crew, types.String, "The number of personnel needed to run or pilot this starship."
21+
field :passengers, types.String, "The number of non-essential people this starship can transport."
22+
23+
field :maxAtmospheringSpeed, types.Int do
24+
description "The maximum speed of this starship in atmosphere. null
25+
if this starship is incapable of atmosphering flight."
26+
property :max_atmosphering_speed
27+
end
28+
1829
field :hyperdriveRating, types.Float, "The class of this starships hyperdrive.", property: :hyperdrive_rating
1930

2031
field :MGLT, types.Int do
@@ -28,23 +39,6 @@ module Types
2839
property :mglt
2940
end
3041

31-
# Transport Interface Fields
32-
33-
field :name, types.String, "The name of this starship. The common name, such as \"Death Star\"."
34-
field :model, types.String, "The model or official name of this starship. Such as \"T-65 X-wing\" or \"DS-1 Orbital Battle Station\"."
35-
36-
field :manufacturer, types.String, "The manufacturer of this starship."
37-
field :costInCredits, types.Float, "The cost of this starship new, in galactic credits", property: :cost_in_credits
38-
field :length, types.Float, "The length of this starship in meters."
39-
field :crew, types.String, "The number of personnel needed to run or pilot this starship."
40-
field :passengers, types.String, "The number of non-essential people this starship can transport."
41-
42-
field :maxAtmospheringSpeed, types.Int do
43-
description "The maximum speed of this starship in atmosphere. null
44-
if this starship is incapable of atmosphering flight."
45-
property :max_atmosphering_speed
46-
end
47-
4842
field :cargoCapacity, types.Float do
4943
description "The maximum number of kilograms that this starship can transport."
5044
property :cargo_capacity

app/models/graph/types/transport_interface.rb

Lines changed: 0 additions & 20 deletions
This file was deleted.

app/models/graph/types/vehicle.rb

Lines changed: 0 additions & 46 deletions
This file was deleted.

test/controllers/graphql_controller_test.rb

Lines changed: 2 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -77,27 +77,6 @@ class GraphQLControllerTest < ActionDispatch::IntegrationTest
7777
{ "name" => "Nien Nunb" }
7878
],
7979
"starshipClass" => "Light freighter"
80-
},
81-
"vehicle" => {
82-
"id" => "82948950",
83-
"name" => "Snowspeeder",
84-
"model" => "t-47 airspeeder",
85-
"cargoCapacity" => 10.0,
86-
"consumables" => "none",
87-
"costInCredits" => nil,
88-
"created_at" => "2014-12-15 12:22:12 UTC",
89-
"crew" => "2",
90-
"length" => 4.5,
91-
"manufacturer" => "Incom corporation",
92-
"maxAtmospheringSpeed" => 650,
93-
"passengers" => "0",
94-
"pilots" => [
95-
{ "name" => "Luke Skywalker" },
96-
{ "name" => "Wedge Antilles" },
97-
{ "name" => "Luke Skywalker" },
98-
{ "name" => "Wedge Antilles" },
99-
],
100-
"vehicleClass"=>"airspeeder"
10180
}
10281
}
10382
}
@@ -109,7 +88,7 @@ class GraphQLControllerTest < ActionDispatch::IntegrationTest
10988

11089
def full_graphql_query
11190
"
112-
query Full($personID: ID, $filmID: ID, $planetID: ID, $starshipID: ID, $speciesID: ID, $vehicleID: ID) {
91+
query Full($personID: ID, $filmID: ID, $planetID: ID, $starshipID: ID, $speciesID: ID) {
11392
person(id: $personID) {
11493
birthYear
11594
eyeColor
@@ -173,22 +152,6 @@ def full_graphql_query
173152
pilots { name }
174153
starshipClass
175154
}
176-
vehicle(id: $vehicleID) {
177-
id
178-
name
179-
model
180-
cargoCapacity
181-
consumables
182-
costInCredits
183-
created_at
184-
crew
185-
length
186-
manufacturer
187-
maxAtmospheringSpeed
188-
passengers
189-
pilots { name }
190-
vehicleClass
191-
}
192155
}
193156
"
194157
end
@@ -199,15 +162,13 @@ def default_variables
199162
film = films(:"a-new-hope")
200163
planet = planets(:alderaan)
201164
species = species(:hutt)
202-
vehicle = vehicles(:snowspeeder)
203165

204166
{
205167
"starshipID" => starship.id,
206168
"personID" => person.id,
207169
"filmID" => film.id,
208170
"planetID" => planet.id,
209-
"speciesID" => species.id,
210-
"vehicleID" => vehicle.id
171+
"speciesID" => species.id
211172
}
212173
end
213174
end

0 commit comments

Comments
 (0)