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

Commit a96a47a

Browse files
authored
Merge pull request #33 from GraphQLAcademy/rating-type
Rating Type
2 parents 7d2e373 + 6ea79a7 commit a96a47a

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

app/models/graph/types/film.rb

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

17+
connection :ratings, Graph::Types::Rating.connection_type
18+
connection :critics, Graph::Types::User.connection_type
19+
1720
field :title, !types.String, "The title of this film"
1821
field :episodeID, !types.Int, "The episode number of this film.", property: :episode_id
1922
field :openingCrawl, !types.String,

app/models/graph/types/person.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ module Types
1212
connection :vehicles, Graph::Types::Vehicle.connection_type
1313
connection :films, Graph::Types::Film.connection_type
1414

15+
connection :ratings, Graph::Types::Rating.connection_type
16+
connection :ratedFilms, Graph::Types::Film.connection_type do
17+
property :rated_films
18+
end
19+
1520
field :birthYear, types.String,
1621
"The birth year of the person, using the in-universe standard of BBY or ABY"\
1722
" - Before the Battle of Yavin or After the Battle of Yavin. The Battle of Yavin"\

app/models/graph/types/rating.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Graph
2+
module Types
3+
Rating = GraphQL::ObjectType.define do
4+
name "Rating"
5+
description "A rating made by a user on a film."
6+
7+
interfaces [GraphQL::Relay::Node.interface]
8+
9+
field :user, !Graph::Types::User, "The critic."
10+
field :film, !Graph::Types::Film, "The rated film."
11+
field :rating, !types.Int, "A film rating from 0 to 5."
12+
field :createdAt, !types.String,
13+
"The ISO 8601 date format of the time that this resource was created.", property: :created_at
14+
field :updatedAt, !types.String,
15+
"The ISO 8601 date format of the time that this resource was updated.", property: :updated_at
16+
end
17+
end
18+
end

0 commit comments

Comments
 (0)