grand-stack / grand-stack-starter

Simple starter project for GRANDstack full stack apps

Home Page:https://grandstack.io/docs/getting-started-grand-stack-starter.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GraphQLError [Object]: Argument "direction" has invalid value "OUT".

dvision1979 opened this issue · comments

Hello guys!

Running the default schema from release 1.0.7 vanilla, just did yarn install then yarn run start throws the following error stack:

$ yarn run start
yarn run v1.22.10
$ npm run build && node build/index.js

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

Successfully compiled 6 files with Babel (801ms).
/Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:240
            throw new graphql.GraphQLError(`Argument "${name}" has invalid value ${graphql.print(valueNode)}.`, valueNode);
            ^

GraphQLError [Object]: Argument "direction" has invalid value "OUT".
    at getArgumentValues (/Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:240:19)
    at /Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:3074:32
    at Array.forEach (<anonymous>)
    at visitorSelector (/Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:3066:32)
    at callMethod (/Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:2726:24)
    at visitFields (/Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:2868:30)
    at visit (/Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:2796:17)
    at /Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:2784:41
    at Array.forEach (<anonymous>)
    at visit (/Users/dionescu/tmp/git/grand-stack-starter-0.1.7/api/node_modules/@graphql-tools/utils/index.cjs.js:2777:37) {
  locations: [ { line: 77, column: 133 } ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Can you please check?
Thank you.

commented

Same error for me, I've got it on the latest as well as 0.4.3. I am on node 12 npm 16 osx 10.15.4. Did you solve it?

commented

@danionescu2007 the issue is fixed for me by removing quotes around OUT or IN in the your_project_directory/src/api/schema.graphql.

For example on line 4 in the default version of the file:
Broke Version:
reviews: [Review] @relation(name: "WROTE", direction: "OUT")

Good Version:
reviews: [Review] @relation(name: "WROTE", direction: OUT)

Repeat this every time there is direction: "IN" or direction: "OUT". After doing that the server starts and runs for me.

Thank you for replying. 👍

I figured it out. I also found out that you can alter the directive by specifying something like:
directive @mutation(from: String, to: String, direction: String)

I got into another issue afterwards, error:

{
  "errors": [
    {
      "message": "Cannot read property 'astNode' of undefined",
      "locations": [
        {
          "line": 31,
          "column": 3
        }
      ],
      "path": [
        "AddInstanceTenant"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "TypeError: Cannot read property 'astNode' of undefined",
            "    at getAdditionalLabels (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/neo4j-graphql-js/dist/utils.js:508:52)",
            "    at relationshipCreate (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/neo4j-graphql-js/dist/translate/mutation.js:870:61)",
            "    at translateMutation (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/neo4j-graphql-js/dist/translate/mutation.js:191:31)",
            "    at cypherMutation (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/neo4j-graphql-js/dist/index.js:311:42)",
            "    at _callee4$ (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/neo4j-graphql-js/dist/index.js:109:31)",
            "    at tryCatch (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/regenerator-runtime/runtime.js:63:40)",
            "    at Generator.invoke [as _invoke] (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/regenerator-runtime/runtime.js:293:22)",
            "    at Generator.next (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/regenerator-runtime/runtime.js:118:21)",
            "    at asyncGeneratorStep (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:5:24)",
            "    at _next (/Users/dionescu/tmp/grand-stack-starter/api/node_modules/@babel/runtime-corejs2/helpers/asyncToGenerator.js:27:9)"
          ]
        }
      }
    }
  ],
  "data": {
    "AddInstanceTenant": null
  }
}

I searched everywhere, nothing 😀

commented

Hmm, I don't see astNode anywhere in my files even. What got it to work for me and connect to my DB(on aws) was to delete everything, reinstall the latest create-grandstack-app, and switch to Node v10. (I was on 12 before and it caused connection issues.

Maybe switching node versions will fix it for you as well. I use nvm.sh to manage it.

Thank you so much for the tips. I will give it a try.

[EDIT]
No luck. What release of grand stack starter are you using?
Thank you.

@danionescu2007 the issue is fixed for me by removing quotes around OUT or IN in the your_project_directory/src/api/schema.graphql.

For example on line 4 in the default version of the file:
Broke Version:
reviews: [Review] @relation(name: "WROTE", direction: "OUT")

Good Version:
reviews: [Review] @relation(name: "WROTE", direction: OUT)

Repeat this every time there is direction: "IN" or direction: "OUT". After doing that the server starts and runs for me.

Thanks. This fixed it for me too. Is this a new breaking change from some updates. Using node v12.18.1

commented

@danionescu2007 the issue is fixed for me by removing quotes around OUT or IN in the your_project_directory/src/api/schema.graphql.
For example on line 4 in the default version of the file:
Broke Version:
reviews: [Review] @relation(name: "WROTE", direction: "OUT")
Good Version:
reviews: [Review] @relation(name: "WROTE", direction: OUT)
Repeat this every time there is direction: "IN" or direction: "OUT". After doing that the server starts and runs for me.

Thanks. This fixed it for me too. Is this a new breaking change from some updates. Using node v12.18.1

I'm not sure what introduced this error, I stumbled across this issue on my first day using grandstack, maybe someone from their team will come along and let us all know.

Yes, very unusual, would like to know more, in the meantime I have made a simple PR to address the issue so that the starter builds.

Hey everyone - this looks to be caused by the recent upgrade of graphql-tools in neo4j-graphql-js, which also moved it from devDependencies to dependencies. More validation was added to directives, removing the logic that used to coerce a String value provided to the @relation directive's direction argument to an enum type value.

I'm very sorry about this - it was missed when looking for breaking changes during the upgrade process. We should have the tests and example schema in neo4j-graphql-js updated shortly to reflect this change.

i've fixed the schema.graphql file as suggested, it works with neo4j sandbox but doesn't work with docker

Sholud i need to issue some commands after i fixed the schema.graphql file end before to launch docker-compose? or docker-compose do the whole job?

C:\PROGETTI\Personali\dacancellare\teloregalo>docker-compose up -d
Creating teloregalo_neo4j_1 ... done Creating teloregalo_api_1 ... done Creating teloregalo_ui_1 ... done
C:\PROGETTI\Personali\dacancellare\teloregalo>docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
244b942c69e8 teloregalo_ui "docker-entrypoint.s…" 10 seconds ago Up 9 seconds 0.0.0.0:3000->3000/tcp teloregalo_ui_1
5b29e097de2f teloregalo_api "docker-entrypoint.s…" 10 seconds ago Exited (1) 4 seconds ago teloregalo_api_1
5ca6a0dc0f40 teloregalo_neo4j "/sbin/tini -g -- /d…" 10 seconds ago Up 10 seconds 0.0.0.0:7474->7474/tcp, 7473/tcp, 0.0.0.0:7687->7687/tcp teloregalo_neo4j_1

C:\PROGETTI\Personali\dacancellare\teloregalo>docker logs teloregalo_api_1

grand-stack-starter-api@0.0.1 start /app
npm run build && node build/index.js

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

Successfully compiled 6 files with Babel.

/app/node_modules/@graphql-tools/utils/index.cjs.js:240
throw new graphql.GraphQLError(Argument "${name}" has invalid value ${graphql.print(valueNode)}., valueNode);
^
GraphQLError: Argument "direction" has invalid value "OUT".
at getArgumentValues (/app/node_modules/@graphql-tools/utils/index.cjs.js:240:19)
at /app/node_modules/@graphql-tools/utils/index.cjs.js:3074:32
at Array.forEach ()
at visitorSelector (/app/node_modules/@graphql-tools/utils/index.cjs.js:3066:32)
at callMethod (/app/node_modules/@graphql-tools/utils/index.cjs.js:2726:24)
at visitFields (/app/node_modules/@graphql-tools/utils/index.cjs.js:2868:30)
at visit (/app/node_modules/@graphql-tools/utils/index.cjs.js:2796:17)
at /app/node_modules/@graphql-tools/utils/index.cjs.js:2784:41
at Array.forEach ()
at visit (/app/node_modules/@graphql-tools/utils/index.cjs.js:2777:37) {
locations: [ { line: 196, column: 133 } ]
}
npm ERR! code ELIFECYCLE
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! /root/.npm/_logs/2021-01-27T19_54_20_643Z-debug.log

This should now be resolved in the latest GRANDstack starter release and also in the create-grandstack-app CLI.