neo4j-graphql / neo4j-graphql-js

NOTE: This project is no longer actively maintained. Please consider using the official Neo4j GraphQL Library (linked in README).
Other
608 stars 148 forks source link

[BUG] Filtering in generated queries get erros #273

Open Crodaycat opened 5 years ago

Crodaycat commented 5 years ago

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:

johnymontana commented 5 years ago

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

Crodaycat commented 5 years ago

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"
  }
luchillo17 commented 5 years ago

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?

michaeldgraham commented 5 years ago

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?

luchillo17 commented 5 years ago

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.

aklen commented 4 years ago

I have the same issue. I'm using:

aklen commented 4 years ago

Tested with

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

jollyoldbloke commented 4 years ago

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

tomdid commented 4 years ago

I am experiencing same issue:

No apollo.

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

Filter works with this setup:

CostaFernando commented 4 years ago

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 commented 4 years ago

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

tecnoloco commented 4 years ago

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"
  }
tatva122 commented 3 years ago

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" }

dryhurst commented 3 years ago

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

michaeldgraham commented 3 years ago

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 ❤️

tatva122 commented 3 years ago

@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.

michaeldgraham commented 3 years ago

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