Installation of the dependencies:
pip install -r requirements.txt
Environment variable OMDB_API_TOKEN should be set to be able to get additional movies data from OMDB.
To run project locally you need to migrate database first then run the server
./manage.py migrate
./manage.py runserver
To run Tests exectue following command:
./manage.py test
Both types in this project have implemented Nodez
interface which means they will have lists of edges that includes node.
Movie type has available following fields that can be included in queries:
- id: stringified ID of the object
- title: String
- year: Int
- rated: String
- released: Date
- runtime: String
- genre: String
- director: String
- writer: String
- actors: String
- plot: String
- language: String
- country: String
- awards: String
- metascore: Int
- imdbRating: Float
- commentSet: Set of edges/nodes of all CommentTypes refferenced to this movie
Allows filtering by:
- Title
- exact value -
title: "Test"
- string contains -
title_Icontains: "es"
- string starts with -
title_Istartswith: "Te"
- exact value -
- Genre
- exact value -
genre: "Test"
- string contains -
genre_Icontains: "es"
- exact value -
- Year
- exact value -
year: 2000
- lower than -
year_Lt: 2005
- greater than -
year_Gt: 1970
- exact value -
Comment type has available following fields that can be included in queries
- id: stringified ID of the object
- body: String
- movie: MovieType
One endpoint is available
It would return a list of all movies
query {
allMovies {
edges {
node {
id
title
}
}
}
}
It has some filters, which are defined in MovieType. For example we can filter all movies that were created before year 2000:
query {
allMovies(year_Lt: 2000) {
edges {
node {
id
title
year
}
}
}
}
Example including commentSet, for all movies from year 1970.
query {
allMovies(year: 1970) {
edges {
node {
id
title
year
commentSet {
edges {
node {
id
body
}
}
}
}
}
}
}
Movie query can get us single Movie object by either id or title (if title is uniqie)
query {
movie(id: "TW92aWVUeXBlOjI=") {
id
title
year
}
}
Gets list of all comments
{
allComments {
id
body
movie {
id
title
}
}
}
Gets single comment based on given ID
{
comment(id: "Q29tbWVudFR5cGU6MQ==") {
id
body
movie {
id
title
year
}
}
}
Mutations are used to create/update objects
This mutation creates new movie object
mutation {
createMovie(title: "Test", year: 2010) {
movie {
id
title
year
}
}
}
This mutation allows to create new comment objects, movie needs to be created first.
mutation {
createComment(body: "Test comment", movieId: "TW92aWVUeXBlOjY=") {
id
body
movie {
id
title
year
}
}
}