Filtering with neo4j-graphql.js appears to be broken

Hi all -

I'm trying to get some filtering working and it's failing... not matter what I add for the filters. Not sure what's going on. My automatic schema has generated all the appropriate filters, but it's not doing anything. It always returns all users (in my use case).

query GetUser {
  User(filter: {username_contains: "tommo"}) {
    id
    firstName
    lastName
    email
    username
    avatar
    displayName
    prefix
    suffix
    phone
    birthday {
      formatted
    }
    tagline
    bio
    homepage
    city {
      name
    }
    state {
      name
    }
  }
}

And just for clarification sake... no... not all users have "tommo" in the name ;-) What's going wrong?

@ tlester did you ever solve this issue? I seem to be having the same problem. filter: is ignoring all filter rules entirely and just returns entire result sets.

No... unfortunately, I had to bail on Neo4j for this reason. I'm now using Slash Graphql (the Dgraph SaaS offering for their Graph DB).

i mean filtering is a pretty big deal, i can't believe this doesn't work.

Agreed. It's a critical cornerstone for my project

what libraries are you using in your project in conjunction with Dgraph/Slash. what are you using to view your graph database is there a program similar to neo4j desktop?

did you have to change much in your project to migrate to the new database?

I'm facing to the same issue.
Bug related on GitHub : https://github.com/neo4j-graphql/neo4j-graphql-js/issues/273

Seems to be a problem of peer dependencies.

@PaulContremoulin removing the "graphql" dependency fixed this issue for me. here is my package.json:

   "dependencies": {
    "apollo-server": "^2.19.0",
    "apollo-server-express": "^2.19.0",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "neo4j-driver": "^4.2.0-alpha01",
    "neo4j-graphql-js": "^2.17.1"
  },

and my index.js (note: im using firebase functions to serve the graphql endpoint and apollo studio for graph versioning and additional documentation)

edit: not sure why i have express in there twice, i'll take a look at that in a second.

const functions = require("firebase-functions")
const express = require("express")
const { makeAugmentedSchema } = require("neo4j-graphql-js")
const { ApolloServer } = require("apollo-server-express")
const neo4j = require("neo4j-driver")
const fs = require("fs")
const dotenv = require("dotenv")
const path = require("path")

dotenv.config()

const { NEO4J_URI, NEO4J_USER, NEO4J_PASSWORD, PORT, APOLLO_KEY } = process.env

// Load GraphQL type definitions from schema.graphql file
const typeDefs = fs
  .readFileSync(path.join(__dirname, "schema.graphql"))
  .toString("utf-8")

const schema = makeAugmentedSchema({
  typeDefs,
})

const loggingConfig = { logging: neo4j.logging.console("debug") }

// Create Neo4j driver instance
const driver = neo4j.driver(
  NEO4J_URI,
  neo4j.auth.basic(NEO4J_USER, NEO4J_PASSWORD),
  loggingConfig,
)

const server = new ApolloServer({
  context: { driver },
  schema,
  introspection: true,
  playground: true,
  engine: {
    reportSchema: true,
    graphVariant: "development",
  },
})

const app = express()

server.applyMiddleware({ app, path: "/", cors: true }) //

exports.api = functions.https.onRequest(app)

i hope this helps someone.

1 Like

Thanks @jonathan, "apollo-server": "^2.14.2" and "neo4j-graphql-js": "^2.14.2" fixed the issue for me. (without graphql dependency)

@PaulContremoulin I'm happy to hear you got it working.

note: I'd accidentally included both "apollo-server": "^2.19.0", and "apollo-server-express": "^2.19.0", in my package.json where one OR the other but not both should be included. that was a typo.