All Projects → neo4j-examples → game-of-thrones

neo4j-examples / game-of-thrones

Licence: other
Neo4j Database of A Song of Ice and Fire - Game of Thrones

Game of Graphs

Creating a Neo4j Graph Database (and more) based on Game of Thrones (A Song of Ice and Fire) data.

Data Source

Westeros data can be retrieved from An API of Ice And Fire by Joakim Skoog.

The repository contains the original JSON files, so we can use them directly.

GraphQL Setup

Schema

See got-schema.graphql

  • Person (name, titles, houses, ...)
  • House (name, allies, follows, followers, founder, words, ...)
  • Seat (name)
  • Region (name)

Spin up a Neo4j Sandbox with the data and push our schema file.

npm install -g neo4j-graphql-cli
neo4j-graphql got-schema.graphql

Data Import

Either run the content of the import scripts got-import.cypher in Neo4j Browser or via cypher-shell

# one of these
apt-get install cypher-shell

brew install cypher-shell

# and then
cypher-shell -a bolt://<sandbox-ip>:<bolt-port> -u neo4j -p <password> < got-import.cypher

# or using Docker

docker run -ti -p `pwd`:/import neo4j /bin/sh -c '/var/lib/neo4j/bin/cypher-shell -a bolt://<sandbox-ip>:<bolt-port> -u neo4j -p <password> < /import/got-import.cypher'

Queries

Via GraphiQL, instructions below copied from Neo4j Sandbox:

  1. Your GraphQL endpoint is available at https://<10-0-1-...-.....>.neo4jsandbox.com/graphql/. We use HTTP Basic Auth, so be sure to set an auth header: Authorization: Basic xYXcXCCXCXCXCXCXCXCXCXCX=

  2. Explore your GraphQL API with our hosted GraphiQL IDE.

Example GraphQL Query

{
  House(name: "House Stark of Winterfell") {
    name
    words
    founder {
      name
    }
    seats {
      name
    }
    region {
      name
    }
    follows {
      name
    }
    followers(first:10) {
      name
      seats { name }
    }
  }
}

  1. Visit the Neo4j Browser. You'll automatically be authenticated.

Example Cypher queries:

MATCH path = (p:Person {name:"Steffon Baratheon"})-[:PARENT_OF*]->()
RETURN path

Other Datasources

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].