Setting Up Neo4j GraphQL Toolbox

Now that you have an overview of the technologies you be using in this course it’s time to get hands-on!

You will start by setting up Neo4j GraphQL Toolbox and connecting it to a Neo4j Sandbox.

Screenshot of the GraphQL toolbox

As part of this course, a Neo4j Sandbox instance has been created for you with the recommendations dataset. This dataset contains all of the details required to populate the Neoflix website.

What is Neo4j Sandbox?

Neo4j Sandbox is a free service that allows you to create pre-populated Neo4j instances completely free of charge. Neo4j Sandbox is the perfect environment for experimenting with Neo4j.

You can log into Neo4j Sandbox and create a database with a number of pre-populated datasets by visiting sandbox.neo4j.com.

Extending Your Sandbox Instance

By default, a Neo4j sandbox instance exists for 3 days. You can extend it for another 7 days by going to the sandbox site and extending it in the details (right-most down arrow) for the recommendations sandbox.

How to extend your Neo4j Sandbox instance

Run this Cypher query in the sandbox to see Movie nodes stored in the sandbox.

cypher
MATCH (m:Movie) RETURN m LIMIT 25

Neo4j GraphQL Toolbox

The Neo4j GraphQL Toolbox is a user interface that allows you, with very little effort, to write and execute GraphQL queries and mutations against your Neo4j database.

Screenshot of the GraphQL toolbox

The toolbox is an IDE on top of the Neo4j GraphQL Library and will support you in understanding how to use GraphQL with a Neo4j database.

Connect to a Neo4j Database

The toolbox needs to connect to a Neo4j database, when you launch the toolbox it will ask you to enter the connection details of your Neo4j database.

Open the toolbox and connect to your Neo4j sandbox:

  1. Open Neo4j GraphQL Toolbox (graphql-toolbox.neo4j.io)

    The GraphQL toolbox connection screen
  2. Enter the following details to connect to your Neo4j sandbox.

    Connection URL

    neo4j+s://{sandbox_host}:{sandbox_boltPort}

    Username

    {sandbox_username}

    Password

    {sandbox_password}

  3. Click Connect

When you first connect to a database, the toolbox prompts you to "Generate type definitions" - click Cancel.

Option to generate GraphQL type definitions

Auto-generated type definitions

The toolbox can generate GraphQL type definitions for you by inspecting the data structure of the database. You will create the type definitions as part of this course and can skip this step.

Create a type definition

To interact with the database using GraphQL you must create a type definition.

  1. Enter the following text into the Type definitions to define a single Movie type.

    GraphQL
    type Movie {
        title: String
    }
    The GraphQL toolbox type definition screen

    You can replace any existing type definitions with these.
  2. Click Build Schema

    Using the Neo4j GraphQL Library a fully functional GraphQL API will be created to query data in your Neo4j Sandbox instance based on the type definitions you created.

Run a GraphQL query

The toolbox will build the schema and display the Query Editor. In the Query Editor you can create GraphQL queries based on the type definitions you created.

The GraphQL query editor screen

You will use this interface to compose and execute GraphQL queries using the data in your Neo4j sandbox and see the results.

This simple GraphQL query will return the titles of all the movies in the sandbox.

GraphQL
{
  movies {
    title
  }
}

Copy this query to the query editor in the GraphQL toolbox and click run.

The GraphQL query editor screen with the above query and run button highlighted

The response panel on the right will display the results of the query.

You have successfully connected the GraphQL Toolbox to your Neo4j sandbox, built a GraphQL schema and have executed a GraphQL query.

What’s Next

Congratulations, you have set up your development environment.

In the rest of the course, you will use the Neo4j GraphQL Toolbox to write GraphQL queries to query the API generated by the Neo4j GraphQL Library.

Lesson Summary

In this lesson, you learned about Neo4j Sandbox and Neo4j GraphQL Toolbox.

In the next lesson, you will learn about the Neo4j GraphQL Library.

Chatbot

Hi, I am an Educational Learning Assistant for Intelligent Network Exploration. You can call me E.L.A.I.N.E.

How can I help you today?