neo4j-graphql-js icon indicating copy to clipboard operation
neo4j-graphql-js copied to clipboard

[BUG] Filtering in generated queries get erros

Open Crodaycat opened this issue 4 years ago • 17 comments

When i try to filter with any field (no matter the type) it throws an error: Query:

query {
  Chat (filter: {roomNumber: 10}) {
    id
    roomNumber
  }
}

Error:

Cannot use GraphQLScalarType \"Int\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.

It also happens with strings:

query {
  Message (filter: {text: "filter string"}) {
    text
  }
}

Error:

Cannot use GraphQLScalarType \"String\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.

We are using:

  • apollo-server: 2.6.4 (Also tried with version 2.6.3)
  • neo4j-driver: 1.7.4
  • neo4j-graphql-js: 2.6.3

Crodaycat avatar Jul 07 '19 19:07 Crodaycat

Could you share the dependencies from package.json? Do you explicitly include graphql in your dependencies?

This could be related to the fact that we need to move graphql-js to a peer dependency, which we plan to do for the 3.0 release. See #249

johnymontana avatar Jul 10 '19 16:07 johnymontana

Here are the deps as well as the development ones:

"dependencies": {
    "apollo-server": "^2.6.4",
    "dotenv-json": "^1.0.0",
    "graphql-auth-directives": "^2.1.0",
    "jsonwebtoken": "^8.5.1",
    "lodash": "^4.17.11",
    "neo4j-driver": "1.7.4",
    "neo4j-graphql-js": "^2.6.3",
    "uuid": "^3.3.2"
  },
  "devDependencies": {
    "@pact-foundation/pact": "^8.2.6",
    "@types/gulp": "^4.0.6",
    "@types/jsonwebtoken": "^8.3.2",
    "@types/lodash": "^4.14.134",
    "@types/node": "^12.0.10",
    "@types/uuid": "^3.4.5",
    "@types/webpack": "^4.4.33",
    "awesome-typescript-loader": "^5.2.1",
    "cross-env": "^5.2.0",
    "gulp": "^4.0.2",
    "nodemon": "^1.19.1",
    "npm-run-all": "^4.1.5",
    "prettier": "^1.18.2",
    "source-map-loader": "^0.2.4",
    "string-loader": "0.0.1",
    "timecop": "git+https://github.com/jamesarosen/Timecop.js.git",
    "ts-node": "^8.3.0",
    "typescript": "^3.5.2",
    "webpack": "^4.35.0",
    "webpack-cli": "^3.3.4"
  }

Crodaycat avatar Jul 13 '19 19:07 Crodaycat

Hey @johnymontana I'm the architect on charge of @Crodaycat, what's the progress of this? not being able to use filters may block our use of filters, which forces us to use custom queries, not ideal, can you help us a bit? or point us the right direction?

luchillo17 avatar Aug 24 '19 21:08 luchillo17

Hey there, this looks like it is a graphql package version dependency issue rather than being specific to filtering. Does the error occur with any other query or operation? Are there any API calls that don't get the error?

michaeldgraham avatar Aug 24 '19 21:08 michaeldgraham

This works:

query {
  Chat(checkIn: {year: 2019 }) { 
	id
	roomNumber
  }
}

query {
  Chat (roomNumber: 1001) {
    id
    roomNumber
  }
}

This doesn't:

{
  Chat(filter: { roomNumber: 1001 }) {
	id
    roomNumber
  }
}

As mentioned only fails when trying to use filter, even the most basic one like the exact value breaks.

luchillo17 avatar Aug 24 '19 22:08 luchillo17

I have the same issue. I'm using:

  • apollo-server: 2.12.0
  • neo4j-driver: 4.0.2
  • neo4j-graphql-js: 2.13.0
  • graphql: 14.6.0

aklen avatar May 11 '20 07:05 aklen

Tested with

  • apollo-server: 2.13.0
  • neo4j-driver: 4.0.2
  • neo4j-graphql-js: 2.14.0
  • graphql: 14.6.0

and works well. So just had to update neo4j-graphql-js and apollo-server!

aklen avatar May 11 '20 07:05 aklen

Just confirming I had the same problem. The temporary fix for me was to downgrade versions as specified by @aklen.

jollyoldbloke avatar Jun 19 '20 14:06 jollyoldbloke

I am experiencing same issue:

  • express-graphql: 0.9.0
  • graphql: 15.2.0
  • neo4j-driver: 4.1.0
  • neo4j-graphql-js: 2.14.3

No apollo.

Edit: Seems to be a problem of peer dependencies between these packages:

Filter works with this setup:

  • express-graphql: 0.9.0
  • graphql: 14.4.1
  • neo4j-driver: 4.1.0
  • neo4j-graphql-js: 2.14.3

tomdid avatar Jul 03 '20 12:07 tomdid

Hello,

@johnymontana , any progress here? Is there a workaround while neo4j-graphql-js 3.0 is not yet released?

I'm using the same package.json as in the GRAND stack Starter repository: https://github.com/grand-stack/grand-stack-starter/blob/master/api/package.json.

But I can't use filter as @luchillo17 .

If I run on the root of my project: npm ls graphql

I get the following "UNMET PEER DEPENDENCY" error: image

CostaFernando avatar Sep 23 '20 16:09 CostaFernando

Hey guys,

I found a workaround that worked for me. As neo4j-graphql-js (actually the package graphql-auth-directives) has graphql@~14.x as dependency (not peer dependency), I added graphql@^14.7.0, as a dependency in my package.json image

and ran:

rm -rf node_modules/
npm cache clean
npm install

Now my filter works!

But I think a long therm solution will be to add graphql-js as a peer dependency instead of a dependency in neo4j-graphql-js.

image

CostaFernando avatar Sep 23 '20 17:09 CostaFernando

Hello everyone, also works with this setup.

"dependencies": {
    "apollo-server-express": "^2.17.0",
    "aws-sdk": "^2.759.0",
    "dotenv": "^8.2.0",
    "graphql": "^14.7.0",
    "neo4j-driver": "4.0.2",
    "neo4j-graphql-js": "2.14.3",
    "uuid": "^8.3.0"
  }

tecnoloco avatar Sep 29 '20 21:09 tecnoloco

Still I am facing same issue with below dependencies.

"dependencies": { "apollo-server-express": "^2.17.0", "bcryptjs": "^2.4.3", "body-parse": "^0.1.0", "dotenv": "^8.2.0", "express": "^4.17.1", "express-graphql": "^0.12.0", "graphql": "^14.7.0", "graphql-tools": "^7.0.1", "jsonwebtoken": "^8.5.1", "lodash": "^4.17.20", "neo4j-driver": "^4.0.2", "neo4j-graphql-js": "^2.14.3" }

tatva122 avatar Dec 04 '20 07:12 tatva122

@tatva122 removing the graphql dependency fixed the issue in my case as i didn't actually need it.

dryhurst avatar Dec 08 '20 01:12 dryhurst

Yeah, this is a tricky issue, we need to upgrade the graphql version the library uses and move to making graphqle a peer dependency - we're looking into it this month ❤️

michaeldgraham avatar Dec 08 '20 01:12 michaeldgraham

@tatva122 removing the graphql dependency fixed the issue in my case as i didn't actually need it.

image image

I am experiencing "MODULE_NOT_FOUND" error when "GraphQL" dependency is removed.

tatva122 avatar Dec 21 '20 06:12 tatva122

https://github.com/neo4j-graphql/neo4j-graphql-js/issues/608

michaeldgraham avatar May 02 '21 04:05 michaeldgraham