Showing results for 
Search instead for 
Did you mean: 

Aura, GraphQl and Grandstack

Node Clone

I build a Grandstack app locally on my desktop connecting to a Neo4j database running locally as well. In order to migrate to the cloud I started looking into Aura and have my database deployed into free and professional tier. Keeping it simple I thought it would be easy to switch my database credentials from localhost to the aura instance. However, simply taking the Aura url and password doesn't seem to work for me. What am I missing? I already tried using bolt+routing as an alternative to neo4j+s, didn't make a difference.
Any help greatly appreciated as I really would like to use the Aura instances.

Thank you in advance, Wolfgang


Hi Wolfgang,

When you say it "doesn't seem to work", are you getting any errors? If so, can you share the stacktrace with us? If it contains any sensitive information please feel free to open a support ticket so you can share just with the Aura Support team.


Node Clone

Hi Cory,
thanks for getting back to me. I simply tried to replace the values in the .env file which is used to store username and password for the database. I am wondering whether there is anything specific in the app that fails, but I cannot see anything.

Here is the stack trace from the log file:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.14.8
3 info using node@v10.15.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle grand-stack-starter-api@0.0.1~prestart: grand-stack-starter-api@0.0.1
6 info lifecycle grand-stack-starter-api@0.0.1~start: grand-stack-starter-api@0.0.1
7 verbose lifecycle grand-stack-starter-api@0.0.1~start: unsafe-perm in lifecycle true
8 verbose lifecycle grand-stack-starter-api@0.0.1~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/whoeck/Applications/newfoundation/api/node_modules/.bin:/.npm/create_react_app:/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/whoeck/anaconda3/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/whoeck/bin/Sencha/Cmd/
9 verbose lifecycle grand-stack-starter-api@0.0.1~start: CWD: /Users/whoeck/Applications/newfoundation/api
10 silly lifecycle grand-stack-starter-api@0.0.1~start: Args: [ '-c', 'npm run build && node build/index.js' ]
11 silly lifecycle grand-stack-starter-api@0.0.1~start: Returned: code: 1 signal: null
12 info lifecycle grand-stack-starter-api@0.0.1~start: Failed to exec start script
13 verbose stack Error: grand-stack-starter-api@0.0.1 start: npm run build && node build/index.js
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:182:13)
13 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:182:13)
13 verbose stack at maybeClose (internal/child_process.js:962:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
14 verbose pkgid grand-stack-starter-api@0.0.1
15 verbose cwd /Users/whoeck/Applications/newfoundation/api
16 verbose Darwin 20.3.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v10.15.0
19 verbose npm v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error grand-stack-starter-api@0.0.1 start: npm run build && node build/index.js
22 error Exit status 1
23 error Failed at the grand-stack-starter-api@0.0.1 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I am using NEO4J_URI=neo4j+s:// and the given password. #NEO4J_ENCRYPTED=true is commented out since I didn't need that locally. I tried to change it, but didn't seem to make a difference.
Here is the error in the console:

wolfgang-hoecks-macbook-pro:api whoeck$ npm start

grand-stack-starter-api@0.0.1 start /Users/whoeck/Applications/newfoundation/api
npm run build && node build/index.js

grand-stack-starter-api@0.0.1 build /Users/whoeck/Applications/newfoundation/api
babel src --out-dir build && shx cp .env build 2>/dev/null || : && shx cp src/schema.graphql build

Successfully compiled 6 files with Babel.
throw new Error('Encryption/trust can only be configured either through URL or config, not both');

Error: Encryption/trust can only be configured either through URL or config, not both
at Object.driver (/Users/whoeck/Applications/newfoundation/api/node_modules/neo4j-driver/lib/index.js:288:13)
at Object. (/Users/whoeck/Applications/newfoundation/api/build/index.js:48:37)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
npm ERR! errno 1
npm ERR! grand-stack-starter-api@0.0.1 start: npm run build && node build/index.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grand-stack-starter-api@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/whoeck/.npm/_logs/2021-02-23T22_54_01_729Z-debug.log

Thank you, Wolfgang

Hi Wolfgang,

I suspect you have NEO4J_ENCRYPTED configured to be true somewhere. Try changing the URI to use neo4j:// instead of neo4j+s://. The only difference between the two is the one connects without encryption, while the other uses encryption. If you define your encryption parameters elsewhere in your config, you can get errors like the one you're seeing.

Give that a go and let us know if that works.

One other thing to point out: moving from a local instance (where you're probably only running a single database) to Aura means you might start seeing errors about the routing table being stale. So make sure your application is using transaction functions. An example of using them is available in the API docs for the JS driver (search for the section titled "Transaction Functions").


Node Clone

Hi Cory,

thank you, removing the "+s" worked and I can now run my react app with the GraphQL backend. I guess it can be simple if one knows how to ;-). I am not an expert developer so some of these nuances get missed. Since I am actually loading the database outside of Aura through an ETL at the moment I should be okay regarding transactions, but I will take a look at your recommendation regarding transactions. My assumption is that this has to do with enabling "mutations" through the grandstack app, which I'm currently not using.

As a next step I tried to do the same credentials swap but now for the Free Aura instance I have running. Here I am still getting an error when trying to run my app, the example should return a simple list of companies. The GraphQL API launches fine, no error log, but on the network side I see the following:

  1. {errors: [{,…}], data: {Company: null}}

  2. data: {Company: null}

1. Company: null
  1. errors: [{,…}]
1. 0: {,…}

  1. extensions: {code: "INTERNAL_SERVER_ERROR",…}
  2. locations: [{line: 2, column: 3}]
  3. message: "Could not perform discovery. No routing servers available. Known routing table: RoutingTable[database=default database, expirationTime=0, currentTime=1614123660116, routers=[], readers=[], writers=[]]"
  4. path: ["Company"]

    1. 0: "Company"

I am assuming that there shouldn't be any difference in using the professional vs free Aura instance? However, when I leave NEO4J_ENCRYPTED=true uncommented the professional works, but free one doesn't with or without it.

Thank you so much, really appreciate the quick insight.

Hi Wolfgang,

That "no routing servers" error is the kind that I was alluding to earlier. Due to its distributed nature and the fact that instances are sometimes changed/removed/added behind the scenes, it's important that your app being able to perform automatic retries and discoveries. If you're running a small, single-instance Neo4j database on your laptop this isn't an issue; but with any kind of distributed architecture (like connecting to a cloud service) it becomes crucial.

The docs above give some examples on how to do this. If you're doing it in Node/JavaScript it would look something like:

var readTxResultPromise = session.readTransaction(txc => {
 var result ='MATCH (person:Person) RETURN AS name')
 return result

So you're building a custom function that explicitly uses either a session.readTransaction() or session.writeTransaction(), depending on the type of query, and calling that function to execute your instead of doing so directly. The driver uses this to know it should perform automatic retries.

Let me know if you have any other questions on this.