-
Notifications
You must be signed in to change notification settings - Fork 0
Exercise 5 #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exercise 5 #7
Conversation
FrauMauz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schon sehr komplex mittlerweile... man sieht, dass viel Arbeit drin steckt !
| We wanted to broaden our horizon by using a graph database because we | ||
| only used RDBM systems. | ||
| Also the Neo4j `cypher` language looked interesting compared to regular SQL. | ||
| And we wanted to support local businesses in these dark times. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you choosed Neo4J - short but totally ok and honest :) one 🌟 for you
| ``` | ||
| $ npm run dev | ||
| ``` | ||
| but you need to start the Neo4j database service first. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice and detailed instructions + scenario architecture choosen ...1x 🌟 for you
| preset: 'ts-jest', | ||
| testEnvironment: 'node', | ||
| }; | ||
| testTimeout: 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how did it work with the timeout of 10000? did you try other testTimeouts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also not sure why this is timeout is important? Did it fail without it?
| lib | ||
| .env | ||
|
|
||
| dev.env |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh the environment variables are added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of ignore the .env , you could use git-crypt
backend/package.json
Outdated
| "dev": "dotenv -e dev.env -- nodemon -e ts src/index.ts", | ||
| "lint": "eslint . --ext .ts", | ||
| "test": "jest" | ||
| "test": "dotenv -e test.env -- jest" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
environment variables for testing 👍
| import {NEO4J_PASSWORD, NEO4J_URI, NEO4J_USER} from "../config/env.config"; | ||
|
|
||
| const drv = driver(NEO4J_URI, auth.basic(NEO4J_USER, NEO4J_PASSWORD)); | ||
| const db: Neo4JDatasource = new Neo4JDatasource(drv); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new Neo4JDatasource(drv); !!! good
| `; | ||
|
|
||
| const data = await mutate({ mutation: SIGNUP_USER, variables: { | ||
| name:"Guy", email:"GUY@GUY.de", password:"123456789" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for testing.. ok
| NEO4J_URI=bolt://18.204.8.8:33335 | ||
| NEO4J_USER=neo4j | ||
| NEO4J_PASSWORD=twos-pages-diagnosis | ||
| NEO4J_DATABASE= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test Variables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐ For requesting a review and reviewing another team's PR.
You asked review from us.. and we are sure that you will review us as soon as you have our request. so this star will be yours for sure...
| dataSources: { | ||
| databaseAPI: DatasourceAPI | ||
| }; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interface for db ... good
| id: '789', | ||
| name: 'Robin', | ||
| email: 'test3@test.de', | ||
| password: generateSHA512Hash('test123') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some test users with their data and hash passwords...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Team!
I really like your thorough Readme, this made it much easier for me to review it! Thanks!
It looks like you have flaky tests. If I do npm run test, I get different errors every time - sometimes also no error.
This is because you're running your test files in parallel - jest is doing that by default. I recommend adding a --runInBand here to change that.
"test": "dotenv -e test.env -- jest --runInBand"
Otherwise a change in your database from one file affects the other.
Once that was solved it looked quite smoothly.
One thing I wonder though... Are you the group that didn't use a locally hosted db at all? So did you only use a hosted/sandbox one online? Is it possible that your test.env contains actual connection data? 😅
As you can guess, this is not how it's supposed to be.
I can only emphasize that starting one with docker is quite easy once you got docker installed. For instance with:
docker run -p 7474:7474 -p 7687:7687 --env=NEO4J_AUTH=NEO4J_USERNAME/NEO4J_PASSWORD neo4j:latest
❌ So feel free to clarify, but it looks like I can't give you a point here:
⭐ For not committing sensitive secrets (e.g. API keys) unencrypted to the repository.
❌ Secondly, I do not see that you deny your requests to your subschema. It would be easiest to set a default deny rule in your main schema so that everything not in that schema gets denied.
⭐ You deny the client to call mutations and queries of your subschema directly.
To conclude:
⭐ For choosing a scenario and writing installation instructions in README.md.
⭐ For explaining WHY you have chosen the scenario in the README.md.
⭐ ⭐ Data created in mutations are persisted and your queries and mutations still work as expected.
⭐ ⭐ Your software tests are free of side effects.
⭐ Your database is never left in an invalid state.
⭐ For requesting a review and reviewing another team's PR.
That makes 8/10 ⭐
| tx.run( | ||
| "MATCH (u:User) WHERE u.id =~ $id RETURN u {.*}", {id: id} | ||
| ).then(result => { | ||
| user = result.records[0].get('u') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just for fetching the first element of the returned results.
| preset: 'ts-jest', | ||
| testEnvironment: 'node', | ||
| }; | ||
| testTimeout: 10000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am also not sure why this is timeout is important? Did it fail without it?
@medizinmensch Here is my answer to our Neo4j journey of problems: The problem is that it seems that Neo4j can not be tested locally on your normal machine. I've written a Moodle Post about it because I looked up the issue and nobody who worked with Neo4j had an actual answer. Robert suggested to mock out the session but then you're miss testing the connection and exception handling when your database fails which is not desirable. The only option we found (without docker) was the sandbox that was presented in the lecture. The problem with docker is that I (for example) cannot use docker because it requires "Hyper-V and Containers Windows features must be enabled" . This is not possible for me because I am using a different hypervisor which is not compatible with Hyper-V. Unfortunately Neo4j's architecture design is bad for using multiple instances because it runs an own service that (at least in free mode) cannot automatically setup a second database for testing. This was the original post:
+++ EDIT:
This is because the sandbox is sometimes slow which leads to failed tests. |
Testing got different errors/no errors each time they ran, because they ran in parallel. Hence they are tested in sequence now.

Pull request for exercise 5.
Replaced InMemoryDatasource with a Neo4j database. Now, results of mutations will be persistent.
Link to the review