forked from Systems-Development-and-Frameworks/homework
-
Notifications
You must be signed in to change notification settings - Fork 0
Neo4j #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
Open
e412
wants to merge
34
commits into
master
Choose a base branch
from
neo4j
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Neo4j #7
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
7895a18
add neo4j driver and neo4j-graphql-js
SyJuly 61fadd9
move data from resolvers to db directory
SyJuly bc202ee
get neo4j driver on local database
SyJuly 840564a
WIP: build backend queries for neo4j
SyJuly 770a785
fix todoById
SyJuly 9929dc0
refactor addTodo
SyJuly d2b99b0
fix updateTodo query
SyJuly 27f39fa
check if todo is from user from token
SyJuly a98f027
delete todo via cypher
SyJuly 0cabc19
add --seed option as args to index.js
SyJuly 7f33715
use uuid for backend id generation
SyJuly 3dc4485
fix deletetodo
SyJuly 8f2a4e7
create backend readme for setup
SyJuly af4336f
userResolvers -> neo4J
e412 bcf6d7e
close session
e412 8cfba4b
adds WHERE, LIMIT, ORDERBY
e412 ad135e7
add neo4j driver to appollo context
SyJuly 6dd4789
force exit
e412 bc139c2
jest
e412 934e571
´test updates
e412 d1a6fb5
travis-update test
e412 881c9ec
travis-update test
e412 e535dc4
travis-update test
e412 9235958
travis-update test
e412 299cd61
travis-update test
e412 1f70174
travis-update test
e412 8644922
try test check
e412 ef31292
setup neo4j service with docker
e412 e7f29f0
adds spacing to docker-compose
e412 336287c
edit docker-compose
e412 ba0069b
change in travis
e412 9b92cdf
edit travis start docker container in detach mode to fix stalled builds
e412 28dd54f
removes not needed lines in docker file for build
e412 9bc7f88
update jest options to display why build is failing
e412 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Backend | ||
|
||
|
||
1. Update packages | ||
- npm install | ||
2. Download [Neo4j Desktop](https://neo4j.com/download/neo4j-desktop/?edition=desktop&flavour=unix&release=1.2.3&offline=true) | ||
3. Create database (*TodoApp*) with password (*password*) | ||
4. Start database, view Neo4j web interface on: | ||
|
||
- bolt://localhost:7687 | ||
- http://localhost:7474 | ||
- https://localhost:7473 | ||
|
||
5. Start backend | ||
|
||
\\Start with seed | ||
node index.js --seed | ||
|
||
\\Start without seed | ||
node index.js | ||
|
||
6. Write queries from GraphQL web interface (http://localhost:4000/) | ||
|
||
## Tips | ||
|
||
##### View whole graph in Neo4j web interface | ||
MATCH (n) | ||
RETURN n | ||
|
||
##### Clear database from everything | ||
start r=relationship(*) delete r; | ||
|
||
MATCH (n) | ||
DETACH DELETE n |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
const { ApolloServer } = require('apollo-server'); | ||
const { ApolloServer, makeExecutableSchema } = require('apollo-server'); | ||
const { mergeResolvers } = require("merge-graphql-schemas"); | ||
const neo4j = require('neo4j-driver'); | ||
const { augmentSchema } = require("neo4j-graphql-js"); | ||
const { seedDatabase } = require("./src/db/seed"); | ||
|
||
const driver = neo4j.driver( | ||
'bolt://localhost', | ||
neo4j.auth.basic('neo4j', 'password'), | ||
{ disableLosslessIntegers: true } | ||
e412 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
) | ||
|
||
// The ApolloServer constructor requires two parameters: your schema | ||
// definition and your set of resolvers. | ||
const { typeDefs } = require('./src/schema/typeDefs'); | ||
|
||
|
||
const { userResolver } = require("./src/resolvers/user/userResolver"); | ||
const { todoResolver } = require("./src/resolvers/todo/todoResolver"); | ||
const resolvers = mergeResolvers([userResolver, todoResolver]); | ||
|
||
const schema = makeExecutableSchema({ typeDefs, resolvers }); | ||
const augmentedSchema = augmentSchema(schema); | ||
|
||
const server = new ApolloServer({ schema: augmentedSchema, context: { driver } }); | ||
|
||
const server = new ApolloServer({ typeDefs, resolvers}); | ||
if (process.argv.length === 3 && process.argv[2] === "--seed") { | ||
seedDatabase(driver) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer a dedicated npm script, I think it's more flexible and simpler, but up to you. |
||
} | ||
|
||
// The `listen` method launches a web server. | ||
server.listen().then(({ url }) => { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
module.exports = { | ||
verbose: true, | ||
moduleFileExtensions: [ | ||
"js", | ||
"json" | ||
], | ||
transform: { | ||
"^.+\\.js$": "<rootDir>/node_modules/babel-jest" | ||
}, | ||
collectCoverage: true, | ||
collectCoverageFrom: [ | ||
"src/components/*.{js}", | ||
"!**/node_modules/**" | ||
], | ||
coverageReporters: [ | ||
"text-summary" | ||
], | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Also wir glauben, dass docker als snap laufen zu lassen nicht unbedingt der beste Ansatz ist (eine Containerumgebung in einer Sandbox hört sich nach Problemen an).
Ihr könnt da auch direkt als Service docker angeben und dann einfach in before_install den offiziellen Neo4j Container hochfahren. Siehe unsere travis.yml bei Interesse
Vielleicht löst das dann auch euer Travis Problem ;)
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.
Wir hatten Probleme damit, dass unser Driver nicht geschlossen wurde und deswegen die Tests endlos liefen. Um das zu lösen, haben wir für den Server eine Cleanup-Funktion implementiert, die bei dessen stop event aufgerufen wird. Leider hat das aber für den Test nichts gebracht, weil der Mockup Server dieses event anscheinend nicht aufruft, weshalb wir die Funktion jetzt immer manuell in afterAll() aufrufen.
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.
Travis CI unterstützt docker: https://docs.travis-ci.com/user/docker/ bei uns nutzen wir docker um die gebauten images zu testen. Docker auf Travis hat natürlich einen Nachteil weil der build server erstmal die ganzen images bauen muss was entsprechend Zeit verbraucht. Jetzt hier bei der Aufgabe werden keine Images gebaut, allerdings ist das caching von npm modules nicht so ohne weiteres möglich.
Die Lösung, den driver im
beforeAll
zu schließen klingt ganz sinnvoll. Alternativ könnt ihr auch globalTeardown nutzen: https://jestjs.io/docs/en/configuration#globalteardown-string