Requested database is not available. Requested database name: 'graph.db' - neo4j

am getting this error message
{
"code": "Neo.TransientError.Database.DatabaseUnavailable",
"message": "Requested database is not available. Requested database name: 'graph.db'."
}
while sending a request through rest API, with this statement
{
"statements" : [ {
"statement" : "CREATE (n) RETURN id(n)"
} ]
}

I'm guessing you probably don't have a database called graph.db. That is the name of the file system directory, not the database. Unless you've set up a database yourself, use neo4j, which is the default.

As Nigel said, it'll be because you don't have a graph by that name.
I ran into this issue recently, after upgrading from 3.5.3 to 4.1, and having to figure out some new behaviours (why yes, I have been living under a rock).
Read through the server's logs - it reports the database name while it's starting up. If you're using a Docker instance, as I am, docker logs <instance-id> is your friend.

Related

How do I insert data to Astra DB using GraphQL API?

I am trying to follow this youtube tutorial.
I am getting stuck at inserting the first piece of data. Ania demonstrates it at 20.46 as follows:
mutation insertGenres {
action: insertreference_list(value: {label: "genre", value: "action"}) {
value{
value
},
}
When I try this, I get an error that says:
{
"errors": [
{
"message": "Validation error of type FieldUndefined: Field 'insertreference_list' in type 'Mutation' is undefined # 'insertreference_list'",
"locations": [
{
"line": 2,
"column": 3
}
],
"extensions": {
"classification": "ValidationError"
}
}
]
}
When I google the error, a lot of responses tell people to use mutations instead of queries - but I've started from a mutation. I would like to know how to resolve the error, but I'd also like to find the skills to improve my search strategy for finding answers.
When I look at the documentation for using GraphQL with DataStax, I see a different format to the write structure, which is as follows:
insertbook(value: bookInput!, ifNotExists: Boolean, options:
UpdateOptions): bookMutationResult
It has a colon and a fragment of text after it. It also explicitly states the ifNotExists: Boolean and options. I don't know if there may have been a change to how to use DataStax since the time Ania recorded the tutorial that means it is no longer a current demonstration of how to use the tool, or if there is an answer for this and I just haven't found it yet.
You didn't provide details of how you've configured your Astra DB for Ania's Netflix Clone tutorial so I'm going to assume that you've named your keyspace as netflix.
It seems as though you haven't followed the instructions correctly and have missed steps. I can replicate the error you reported if I skip at least one of the steps in the tutorial.
In step 5 of the tutorial, you needed to do the following:
✅ In graphQL playground, change tab to now use graphql. Edit the end of the URl to change from system to the name of your keyspace: netflix
✅ Populate HTTP HEADER variable x-cassandra-token on the bottom of the page with your token as shown below (again !! yes this is not the same tab)
Switch tabs
In order to insert data, you need to switch to the graphql tab.
If you try to insert the data in the graphql-schema tab, you will get the error you reported.
Set keyspace
You need to update the URI of your GraphQL playground in the graphql tab to use the keyspace name netflix instead of system. For example:
https://db_id-us-west1.apps.astra.datastax.com/api/graphql/system
change to:
https://db_id-us-west1.apps.astra.datastax.com/api/graphql/netflix
If you try to insert data into the system keyspace, you will get the error you reported because the reference_list table does not exist in that keyspace. Cheers!

Serverless - Change the content before deploy

I'm using Serverless for working with our aws lambda / appsync.
For Error Handling, we are keep erro code with message in a json file. The Codes will be unique. Something like this:
//error-code.json
{
"1"": { code: 1, message: "Invalid User Input"},
"2"": { code: 2, message: "Invalid Input"},
//... so on
}
This wil lbe deploy as layer and all the lambda will use it. Issue is we cannot use it in the resolve template. There are some of the resolver will be only template file. These template files cannot access the json file nor can access the layer. How can I use the error-code.json here?
Solution 1:
Manually write the error code in templates and make sure there are alway unique. Something like this:
#set(#errorInfo = {
"erroCode": "1",
"errorMessage": "Invalid Input"
})
$util.error("Invalid Input", "errorType", $ctx.arguments,#errorInfo)
Rejected: Becasue we have to manually check everytime for the unique of error code. In case of lot of template file, we cannot rely on it.
Solution 2:
Create a table with error code (unique) and error message. Use this table to send error from template.
Rejected: Because we use multiple app sync instance and they all connect to dirferent database. So we have to make this table in all database, and thus unique across the app-sync is not maintained.
Solution 3:
Write the placeholder in vtl where we want to send the error. Before Deploy, replace the placeholder with the actual code using pre-hook script, but not in the actual vtl file but in the generated package that serverless deploy. Does Serverless even such thing?
if your errors are all static, there is one more option for consideration.
You create one more file that holds all errors defined in Velocity.
$util.qr( $ctx.stash.put("errors", {}) ) $util.qr(
$util.qr( $ctx.stash.errors.put("ONE", { "code": 1, "message": "Invalid User
Input"} )
...
$util.qr( $ctx.stash.errors.put("TWENTY", { "code": 20, "message": "20th error description"} )
For every velocity resolver that throws errors, you inject pre-defined errors at the beginning of its request mapping's file. Whenever you want to throw an error, it's done by retrieving a pre-defined error from $ctx.stash
$util.error ( $ctx.stash.errors.ONE.message, $ctx.stash.errors.ONE.code )
The error file is generated from error-code.json, or manually typed again for simplicity. $ctx.stash is used because stash is accessible from everywhere in a resolver, including pipeline ones.

How do I display data from Rails backend to Ember frontend without saving it in the database and without using Ember-Data?

The problem:
I have used rest-client to pull news articles from newsapi.org through my Rails backend. I can display that data on localhost:3000/articles. I do not (necessarily) want to save this data to a database and would like to simply display it on my Ember frontend after calling it on my Rails backend. I get this error:
Error while processing route: article Assertion Failed: You must include an 'id' for article in an object passed to 'push'
I understand this to mean that my data has no 'id' - which it doesn't. I have no control over the data coming in.
{
"status": "ok",
"totalResults": 6868,
"articles": [
{
"source": {
"id": "mashable",
"name": "Mashable"
},
"author": "Lacey Smith",
"title": "Cannabis may alter the genetic makeup of sperm",
"description": "A new study suggests that marijuana use can not
only lower sperm count, but also affect sperm DNA. Read more... More
about Marijuana, Cannabis, Sperm, Science, and Health",
"url": "https://mashable.com/video/cannabis-sperm-dna/",
"content": null
},
Ember-Data doesn't like this because it's not in JSONAPI format and I can't change it to JSONAPI. How do I display this data on my ember frontend without using Ember-Data and without having to save it into my database? The tutorials I've found all have examples using databases and Ember-Data.
What I've already tried:
I tried to save it to my database and load from there, but I'm thinking that might complicate the idea, since I would need to scrape the data and save it to my database and that has proven difficult to do. I'm not experienced with backend stuff and haven't found many answers. If you have an answer for doing it this way, feel free to answer here:
How to automatically save data from url to database
I'm willing to try it out. I thought originally this would be the best way to go. I could save the data and only add to the database when new articles were returned. I'm not having any luck this way, so I thought I'd approach it from another direction.
Thanks for any help!
If you want to do some processing outside of ember-data, create a service. In your service, you will need to then make an ajax/fetch request to your backend. Let's say you are using ember-ajax to make your requests:
import Service, { inject } from '#ember/service';
export default Service.extend({
// inject the ember-ajax ajax service into your service
ajax: inject(),
//this returns a promise
getNewsItems(){
var options = {
// request options (aka anything needed to authenticate against your api, etc)
};
let url = "yourBackendEndpoint/for/this/resource";
return request(url, options).then(response => {
// `response` is the data from the server
// here you want to convert the JSON into something useable
return response;
});
}
});
Then, let's say in a model hook for some route, you needed this service (which we will say is defined in your-app/services/my-service.js) to fetch the news feed items:
import Route from '#ember/route';
import { inject } from '#ember/service';
export default Route.extend({
myService: inject(),
model(){
let myService = this.get('myService');
return myService.getNewsItems();
}
)
I personally use ember-fetch which avoids the jQuery dependency and is useable in all target browsers for my app. I do not use ember-data in any of my apps.

Is Parse's server down ahead of schedule or am I missing something?

I haven't been able to contact Parse's server at all of the past week,
when I try to deploy my Cloud Code, the CLI gives me the following error:
When I try to add a new Cloud Code I get this error:
And back in Xcode, when I try to run my application, I get this error:
What is the issue here? And is there any fix to this?
I See that the errors have a sort of reference to go Lang, what does that have to do with the situation ?
Parse is (obviously) still available (for now!). It looks like an authorization error (i.e. wrong keys setup). Two things:
1. Update your Parse CLI SDK
Run an update to grab the latest parse CLI SDK:
`$ parse update`
Check your config.json has the correct keys in it
In your cloud code directory, there is a config/global.json file. This is what the ParseSDK uses to authenticate against Parse.com. Check the keys are correct for your app(s):
{
"global": {
"parseVersion": "1.4.2"
},
"applications": {
"YourAppName": {
"applicationId": "THE APP KEY HERE",
"masterKey": "THE MASTER KEY HERE"
},
"_default": {
"link": "YourAppName"
}
}
}

Unable to authenticate mongodb remotely

I am unable to authenticate mongodb remotely. I'm running MongoDB 3.0.0 provided by the DigitalOcean One-Click installer, and I can't seem to set up authentication properly.
I have 1 database called wbio_production. I followed mongodb docs tutorials as best as I could. When I execute:
> db.auth("siteUserAdmin","MYPASSWORD")
1
> db.getUsers()
The output of that is:
{
"_id" : "admin.siteUserAdmin",
"user" : "siteUserAdmin",
"db" : "admin",
"roles" : [
{
"role" : "userAdminAnyDatabase",
"db" : "admin"
}
]
}
And when I switch to the wbio_production database and perform the same getUsers():
> use wbio_production
switched to db wbio_production
> db.getUsers()
[
{
"_id" : "wbio_production.herokuUser",
"user" : "herokuUser",
"db" : "wbio_production",
"roles" : [
{
"role" : "userAdmin",
"db" : "wbio_production"
},
{
"role" : "readWrite",
"db" : "wbio_production"
}
]
}
]
When I fill out the connection form in Robomongo however, it cannot successfully connect to the database. Authorization always fails, however it does successfully connect to the database.
I have tried the following combinations of using the users above:
DB: Admin, User: siteUserAdmin
DB: Admin, User: herokuUser
DB: wbio_production, User: siteUserAdmin
DB: wbio_production, User: herokuUser
All of them wind up with some output coming back in the heroku logs similar:
failed with error 13: "not authorized for query on
wbio_production.mongoid_forums_forums"
I have tried reinstalling mongodb, recreating users based off different tutorials, and just trying different peoples explanations. I've spent about 5 hours now looking for a solution to my issue, and now I must turn to SO for your advice. I'm sure this is a simple error on my part that I am not understanding from the docs or something I am continuously missing in the set up.
What must I do to get a secured and functional MongoDB server? Thanks!
You need to configure mongod with its binding so clients can connect remotely.
bind_ip = 0.0.0.0
Robomongo authentication does not work with MongoDB 3+. I recommend switching over to MongoChef. http://3t.io/mongochef/. I highly recommend it, as it contains MANY more capabilities than Robomongo does.
Another thing to keep in the back of your mind...
If you are also using Mongoid, it is currently undergoing a large rewrite. Mongoid 5 will drop Moped https://www.mongodb.com/blog/post/announcing-ruby-driver-20-rewrite.
Take a look at my other answer on what to do if you are using Mongoid 4 with MongoDB 3+. Rails Mongoid fails to authenticate - failed with error 13: "not authorized for query on my_db.my_collection"

Resources