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
3 changes: 3 additions & 0 deletions app/models/graph/types/film.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions app/models/graph/types/person.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"\
Expand Down
18 changes: 18 additions & 0 deletions app/models/graph/types/rating.rb
Original file line number Diff line number Diff line change
@@ -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