Giter Club home page Giter Club logo

graphy's Introduction

Configuration

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.

Running project

To run project locally you need to migrate database first then run the server

./manage.py migrate
./manage.py runserver

Running tests

To run Tests exectue following command:

./manage.py test

Types

Both types in this project have implemented Nodez interface which means they will have lists of edges that includes node.

Movie

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:

  1. Title
    • exact value - title: "Test"
    • string contains - title_Icontains: "es"
    • string starts with - title_Istartswith: "Te"
  2. Genre
    • exact value - genre: "Test"
    • string contains - genre_Icontains: "es"
  3. Year
    • exact value - year: 2000
    • lower than - year_Lt: 2005
    • greater than - year_Gt: 1970

Comment

Comment type has available following fields that can be included in queries

  • id: stringified ID of the object
  • body: String
  • movie: MovieType

Endpoint /graphql

One endpoint is available

Queries

allMovies

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

Movie query can get us single Movie object by either id or title (if title is uniqie)

query {
  movie(id: "TW92aWVUeXBlOjI=") {
    id
    title
    year
  }
}

allComments

Gets list of all comments

{
  allComments {
    id
    body
    movie {
      id
      title
    }
  }
}

comment

Gets single comment based on given ID

{
  comment(id: "Q29tbWVudFR5cGU6MQ==") {
    id
    body
    movie {
      id
      title
      year
    }
  }
}

Mutations

Mutations are used to create/update objects

createMovie

This mutation creates new movie object

mutation {
  createMovie(title: "Test", year: 2010) {
    movie {
      id
      title
      year
    }
  }
}

createComment

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
    }
  }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.