Your challenge is to add a new driver instance to an existing file with the connection details provided. Once you have created the driver, you will need to open a new session and execute a Cypher statement to find the director of the movie Toy Story.
We have created a repository for this course. It contains the starter code and resources you need.
A Neo4j Sandbox instance has also been created for you to use during this course.
Setup
You will need Go installed and the ability to install the Neo4j driver using go get.
Clone the https://github.com/neo4j-graphacademy/app-go repository:
git clone https://github.com/neo4j-graphacademy/app-goSetup environment variables for the connection to the Neo4j Sandbox instance:
- NEO4J_URI
 - 
bolt://{instance-ip}:{instance-boltPort}
 - NEO4J_USERNAME
 - 
{instance-username}
 - NEO4J_PASSWORD
 - 
{instance-password}
 
Steps
Open the pkg/challenges/create_driver/challenge.go file:
- 
Install the Neo4j Go Driver in the integrated terminal window
Unresolved directive in lesson.adoc - include::{repository-raw}/main/README.adoc[tag=install]
 - 
Import the
github.com/neo4j/neo4j-go-driver/v5/neo4jsymbol and use theneo4jobject to create a new instance of the Driver withUri,UsernameandPasswordcredentials provided obtained using theGetNeo4jCredentials()method - 
Once you have created the Driver, open a new session and execute the following
cypherstatement using theparamsmap.cypherFind the DirectorMATCH (p:Person)-[:DIRECTED]->(:Movie {title: $title}) RETURN p.name AS Director - 
To find the answer, click the Debug icon to the left of the IDE window and run Create Driver Challenge task, or use the integrated terminal window to run the following command:
shRun The Challengego run pkg/challenges/create_driver/challenge.go - 
Once you have the result, copy and paste it into the text box below and click Check Answer.
 
Your Answer
Who directed Toy Story?
Take the Director value output from the statement above and paste it into the box below.
- 
✓ John Lasseter
 
Hint
You need to call the neo4j.NewDriverWithContext() object to create a Driver instance using the Uri, Username and Password variables provided by the GetNeo4jCredentials() function, then open a new session, execute the Cypher statement and log the Director value of the first record.
Once you have a result object, use the neo4j.SingleTWithContext() function to extract the Director value from the first record.
Your fmt.Println() call should look similar to the code block below:
fmt.Println(director)Copy the answer without any quotes or whitespace.
Solution
John Lasseter directed Toy Story.
You can compare your code with the solution here.
Unresolved directive in questions/1-director.adoc - include::{repository-raw}/main/pkg/challenges/create_driver/solution/solution.go[]Lesson Summary
In this challenge, you used your knowledge to create a driver instance and execute a Cypher statement.
In the next lesson, you will learn about the different transaction functions and when to use them.