diff --git a/app/models/graph/types/film.rb b/app/models/graph/types/film.rb index 959537a..c89bf52 100644 --- a/app/models/graph/types/film.rb +++ b/app/models/graph/types/film.rb @@ -14,6 +14,9 @@ module Types connection :characters, Graph::Types::Person.connection_type connection :planets, Graph::Types::Planet.connection_type + connection :ratings, Graph::Types::Rating.connection_type + connection :critics, Graph::Types::User.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, diff --git a/app/models/graph/types/person.rb b/app/models/graph/types/person.rb index 0b77a6a..959093f 100644 --- a/app/models/graph/types/person.rb +++ b/app/models/graph/types/person.rb @@ -12,6 +12,11 @@ module Types connection :vehicles, Graph::Types::Vehicle.connection_type connection :films, Graph::Types::Film.connection_type + connection :ratings, Graph::Types::Rating.connection_type + connection :ratedFilms, Graph::Types::Film.connection_type do + property :rated_films + end + 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"\ diff --git a/app/models/graph/types/rating.rb b/app/models/graph/types/rating.rb new file mode 100644 index 0000000..9219497 --- /dev/null +++ b/app/models/graph/types/rating.rb @@ -0,0 +1,18 @@ +module Graph + module Types + Rating = GraphQL::ObjectType.define do + name "Rating" + description "A rating made by a user on a film." + + interfaces [GraphQL::Relay::Node.interface] + + field :user, !Graph::Types::User, "The critic." + field :film, !Graph::Types::Film, "The rated film." + field :rating, !types.Int, "A film rating from 0 to 5." + field :createdAt, !types.String, + "The ISO 8601 date format of the time that this resource was created.", property: :created_at + field :updatedAt, !types.String, + "The ISO 8601 date format of the time that this resource was updated.", property: :updated_at + end + end +end