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

Commit 7e66c35

Browse files
authored
Merge pull request #25 from GraphQLAcademy/non-null-fields
Add non-null to fields
2 parents be0cfe9 + fc4d088 commit 7e66c35

File tree

7 files changed

+23
-23
lines changed

7 files changed

+23
-23
lines changed

app/models/graph/types/film.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,22 @@ module Types
1414
connection :characters, Graph::Types::Person.connection_type
1515
connection :planets, Graph::Types::Planet.connection_type
1616

17-
field :title, types.String, "The title of this film"
18-
field :episodeID, types.Int, "The episode number of this film.", property: :episode_id
19-
field :openingCrawl, types.String,
17+
field :title, !types.String, "The title of this film"
18+
field :episodeID, !types.Int, "The episode number of this film.", property: :episode_id
19+
field :openingCrawl, !types.String,
2020
"The opening paragraphs at the beginning of this film.", property: :opening_crawl
2121

22-
field :director, types.String, "The name of the director of this film."
23-
field :producers, types[types.String] do
22+
field :director, !types.String, "The name of the director of this film."
23+
field :producers, !types[!types.String] do
2424
description "The name(s) of the producer(s) of this film."
2525
resolve ->(film, _, _) { film.producer.split(", ") }
2626
end
2727

28-
field :releaseDate, types.String,
28+
field :releaseDate, !types.String,
2929
"The ISO 8601 date format of film release at original creator country.", property: :release_date
3030

31-
field :created_at, types.String, "The ISO 8601 date format of the time that this resource was created."
32-
field :updated_at, types.String, "The ISO 8601 date format of the time that this resource was edited."
31+
field :created_at, !types.String, "The ISO 8601 date format of the time that this resource was created."
32+
field :updated_at, !types.String, "The ISO 8601 date format of the time that this resource was edited."
3333
end
3434
end
3535
end

app/models/graph/types/person.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ module Types
3030
field :height, types.Int, "The height of the person in centimeters."
3131
field :homeworld, Planet, "A planet that this person was born on or inhabits."
3232
field :mass, types.Int, "The mass of the person in kilograms."
33-
field :name, types.String, "The name of this person."
33+
field :name, !types.String, "The name of this person."
3434
field :skinColor, types.String, "The skin color of this person.", property: :skin_color
3535
end
3636
end

app/models/graph/types/planet.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Types
1111
connection :films, Graph::Types::Film.connection_type
1212
connection :residents, Graph::Types::Person.connection_type
1313

14-
field :name, types.String, "The name of this planet."
14+
field :name, !types.String, "The name of this planet."
1515
field :diameter, types.Int, "The diameter of this planet in kilometers."
1616

1717
field :rotationPeriod, types.Int,

app/models/graph/types/species.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module Types
1111
connection :people, Graph::Types::Person.connection_type
1212
connection :films, Graph::Types::Film.connection_type
1313

14-
field :name, types.String, "The name of this species."
14+
field :name, !types.String, "The name of this species."
1515
field :classification, types.String, "The classification of this species, such as \"mammal\" or \"reptile\"."
1616
field :designation, types.String, "The designation of this species, such as \"sentient\"."
1717

@@ -41,7 +41,7 @@ module Types
4141
end
4242
end
4343

44-
field :skinColors, types[types.String] do
44+
field :skinColors, types[!types.String] do
4545
description "Common skin colors for this species, null if this species does not typically have skin."
4646
resolve ->(species, _, _) do
4747
return unless colors = species.skin_colors

app/models/graph/types/starship.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ module Types
1010

1111
# Starship Specific Fields
1212

13-
field :starshipClass, types.String do
13+
field :starshipClass, !types.String do
1414
description "The class of this starship, such as \"Starfighter\" or \"Deep Space Mobile Battlestation\""
1515
property :starship_class
1616
end
1717

18-
field :hyperdriveRating, types.Float, "The class of this starships hyperdrive.", property: :hyperdrive_rating
18+
field :hyperdriveRating, !types.Float, "The class of this starships hyperdrive.", property: :hyperdrive_rating
1919

20-
field :MGLT, types.Int do
20+
field :MGLT, !types.Int do
2121
description "
2222
The Maximum number of Megalights this starship can travel in a standard hour.
2323
A \"Megalight\" is a standard unit of distance and has never been
@@ -30,7 +30,7 @@ module Types
3030

3131
# Transport Interface Fields
3232

33-
field :name, types.String, "The name of this starship. The common name, such as \"Death Star\"."
33+
field :name, !types.String, "The name of this starship. The common name, such as \"Death Star\"."
3434
field :model, types.String, "The model or official name of this starship. Such as \"T-65 X-wing\" or \"DS-1 Orbital Battle Station\"."
3535

3636
field :manufacturer, types.String, "The manufacturer of this starship."
@@ -53,8 +53,8 @@ module Types
5353
field :consumables, types.String, "The maximum length of time that this starship can provide consumables for its entire crew without having to resupply."
5454
connection :pilots, Graph::Types::Person.connection_type
5555

56-
field :created_at, types.String, "The ISO 8601 date format of the time that this resource was created."
57-
field :updated_at, types.String, "The ISO 8601 date format of the time that this resource was updated."
56+
field :created_at, !types.String, "The ISO 8601 date format of the time that this resource was created."
57+
field :updated_at, !types.String, "The ISO 8601 date format of the time that this resource was updated."
5858
end
5959
end
6060
end

app/models/graph/types/transport_interface.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module Types
44
name "Transport"
55
description "A single transport craft"
66

7-
field :name, types.String
7+
field :name, !types.String
88
field :model, types.String
99
field :manufacturer, types.String
1010
field :costInCredits, types.Float

app/models/graph/types/vehicle.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ module Types
1010

1111
# Vehicle Specific Fields
1212

13-
field :vehicleClass, types.String do
13+
field :vehicleClass, !types.String do
1414
description "The class of this vehicle, such as \"Wheeled\" or \"Repulsorcraft\"."
1515
property :vehicle_class
1616
end
1717

1818
# Transport Interface Fields
19-
field :name, types.String, "The name of this vehicle. The common name, such as \"Sand Crawler\" or \"Speeder bike\""
19+
field :name, !types.String, "The name of this vehicle. The common name, such as \"Sand Crawler\" or \"Speeder bike\""
2020
field :model, types.String, "The model or official name of this vehicle. Such as \"All-Terrain Attack Transport\"."
2121

2222
field :manufacturer, types.String, "The manufacturer of this vehicle."
@@ -39,8 +39,8 @@ module Types
3939
field :consumables, types.String, "The maximum length of time that this vehicle can provide consumables for its entire crew without having to resupply."
4040
connection :pilots, Graph::Types::Person.connection_type
4141

42-
field :created_at, types.String, "The ISO 8601 date format of the time that this resource was created."
43-
field :updated_at, types.String, "The ISO 8601 date format of the time that this resource was updated."
42+
field :created_at, !types.String, "The ISO 8601 date format of the time that this resource was created."
43+
field :updated_at, !types.String, "The ISO 8601 date format of the time that this resource was updated."
4444
end
4545
end
4646
end

0 commit comments

Comments
 (0)