GraphQL vs Graph Databases for Recruiters

GraphQL vs Graph Databases for Recruiters

Unlike the Java Vs JavaScript topic I tackled last week, these two are not even in the same category. But I have heard both recruiters and inexperienced developers confuse these topics more than once so the confusion must be real and I figured I would address it.

What is GraphQL

GraphQL is a data transfer protocol like REST (I will do a post about REST at some point). In many ways it is a successor to REST and many people (including myself) are predicting it will supersede REST as the dominant technology used to build APIs in the future.

Okay, enough jargon, what does that mean? An API (Application Programming Interface) is a way to expose data and accept input from remote applications. Let me explain an API using a real world example:

When you pull up the Uber app on your phone it is going to call your phone's API to get your GPS location, Uber's API to get nearby cars, and Google Maps API to render the map centered on your location. When you request an ride you are calling Uber's API with data of your ride request.

So GraphQL is just another way to write APIs. With GraphQL you define a "schema" (a schema is a description of what your data looks like), and then you interact with the schema using the GraphQL query language (which does let query as though your data is a "graph", which I will explain later).

So to use GraphQL you must run a GraphQL server, set up a schema, and then write queries from your client to get and submit data. A very popular piece of software that makes this easy is Apollo. You will probably see references to Apollo Server and Apollo Client on resumes.

What is a Graph Database?

A graph database is a type of database that represents data in the form of a graph. A graph is not like a chart, a graph is a very specific computer science concept which is a type of abstract data type. Even more confusingly graph databases don't necessarily store graphs as a graph, they might just make it queryable as such.

Some examples of Graph Databases:

  • Neo4j
  • OrientDB
  • ArangoDB
  • SAP HANA

What is a Graph Data Structure

The key to understanding a graph database is just to understand what a Graph is. The most intuitive way to understand a graph is to think about a social network. Think about all of the people you know, some of them know you (your friends and family), and some of them don't know you (Kanye West, Boris Johnson, ect).

All of the people in your social network are "Nodes". All of the relationships are "Edges", and edges can have directions. For example, you know your mother, and you mother knows you. But you both know Kanye West and he knows neither you or your mother. Therefore that is a one way relationship, the edge only goes on direction.

Graphs may also have complex circular relationships. Consider you, Fred, Mary, and Joe. You are friends with Fred. Fred is dating Mary. Mary went to school with Joe and knows him. And you work with Joe. You, yourself don't know Mary and she doesn't know you. So the graph looks like this:

You <-> Fred <-> Mary <-> Joe <-> You.

You all know Kanye West (sorry just had to throw that in there again).

Fred Joe Mary Kanye Graph

A graph database is just going to store your data and make it so you can Query it like a graph.

graphql vs graphdb

So why is GraphQL called GraphQL?

GraphQL is called "GraphQL" because you really can query into the data as though it was a graph. Imagine a candidate tracking software. You have the following entities:

  1. Candidate
  2. Recruiter
  3. Company
  4. JobPosting

Even though your database could be relational, or even the underlying data source could be an API server you can write a query like you are getting data via graph relationships.

Here is an example: You search for for Company X, then you get every job posting that company has posted, and then you get every candidate that has applied to each of these job postings. Graphql makes is very easy to pull back this tree of data. The query could look like:

query {
  company(id: 12345) {
    name
    description
    jobPostings {
      name
      jobTitle
      salaryRange
      datePosted
      applicants {
        firstName
        lastName
        email
      }
    }
  }
}

The takeaway

GraphQL is way of transferring data and it is a technology to build APIs with. Graphs are an abstract data type in computer science, and Graph Databases just organize your data in the form of a graph. GraphQL is named the way it is because it allows you to query any data source as though it was organized as a graph.

I am launching a video course for tech recruiters where I will cover many more topics like this, if that sounds interesting please drop your email below.