Neo4j Database of A Song of Ice and Fire - Game of Thrones
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
article.md
got-cypher-parents.jpg
got-graph.jpg
got-graphiql.jpg
got-graphql-schema-voyager.jpg
got-graphql-schema.jpg
got-import-api.cypher
got-import.cypher
got-schema.graphql
neo4j-graphql-cli.jpg
neo4j-graphql-sandbox.jpg
readme.md

readme.md

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