Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
11-09-2022 10:39 PM - edited 11-10-2022 03:07 PM
BH trying to follow this tutorial https://neo4j.com/developer/graphql/ but when I enter the exact query they say to with the exact same nodejs code I get the following error [![enter image description here](https://i.stack.imgur.com/l212C.jpg)](https://i.stack.imgur.com/l212C.jpg) Essentially "expression in call return must be aliased"? Here is the graphql query I made based off of the tutorial, same exact structure:
mutation {
createMovies(
input: [
{
title: "Awtsmoos"
actors: {
create: [
{
node: {
name: "Zalman"
}
}
]
}
}
]
) {
movies {
title
actors {
name
}
}
}
}
And here is the error I get:
{
"errors": [
{
"message": "Expression in CALL { RETURN ... } must be aliased (use AS) (line 17, column 16 (offset: 580))\n\" RETURN collect(NULL)\"\n ^",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"createMovies"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"exception": {
"code": "Neo.ClientError.Statement.SyntaxError",
"name": "Neo4jError",
"retriable": false
}
}
}
],
"data": null
}
Here is the nodejs when the credentials removed
//B"H
const { gql, ApolloServer } = require("apollo-server");
const { Neo4jGraphQL } = require("@neo4j/graphql");
const neo4j = require("neo4j-driver");
const typeDefs = gql`
type Movie {
title: String!
year: Int
plot: String
actors: [Person!]! @relationship(type: "ACTED_IN", direction: IN)
}
type Person {
name: String!
movies: [Movie!]! @relationship(type: "ACTED_IN", direction: OUT)
}
`;
const driver = neo4j.driver(
"neo4j+s://myid.databases.neo4j.io",
neo4j.auth.basic(
"neo4j",
"mypassword"
)
);
const neoSchema = new Neo4jGraphQL({ typeDefs, driver });
neoSchema.getSchema().then((schema) => {
const server = new ApolloServer({
schema: schema,
introspection: true,
playground: true
});
server.listen({port: process. env.PORT}).then(({ url }) => {
console.log(`GraphQL server ready on ${url}`);
});
});
Here is my package.json ```
{
"name": "hi",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start":"node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@neo4j/graphql": "^3.12.0",
"apollo-server": "^3.11.1",
"graphql": "^16.6.0",
"neo4j-driver": "^5.2.0"
}
}
I've tried multiple neo4j servers. I have only been able to run nodejs using heroku, and localhost on debian. Tried testing it with a google cloud VM instance but wasn't able to get an https server up.
11-18-2022 08:39 AM
Hello @Anonymous
Thank you for posting to the Community. I wanted to see if you were able to resolve this issue. If so, can you please post your solution? If you are still having trouble, please let me know!
11-20-2022 03:23 PM
Hi.
I haven't fully tested anything, but I copied the code from the instructions in AuraDB for graphql, started new folder etc a few days ago and reinstalled all the dependencies, at first I got an error, then I changed a line of the built in cypher in the example that says `MATCH(this)` (for the friend count) and rewrote it without "this", and there is no more error. I tried some other examples from the original page here and there were no more errors.
I think it has to do with selecting the "context" of the database, or maybe at the time I tried this there was a mixture of versions which may have been causing problems(even the official graphql beginner documentation was full of errors at the time, even in their own website, which I see has been fixed soon after the release of version 5)
11-22-2022 11:53 AM
AuraDB is now running Neo4j 5 by default.
I think you either need to upgrade the neo4j/graphql dependency to the latest version. 3.12.2 https://www.npmjs.com/package/@neo4j/graphql
or use the Neo4j 4 version on AuraDB
All the sessions of the conference are now available online