neo4j / graphql

A GraphQL to Cypher query execution layer for Neo4j and JavaScript GraphQL implementations.
https://neo4j.com/docs/graphql-manual/current/
Apache License 2.0
496 stars 148 forks source link

graphql-ogm with aggregations and full text searches #5345

Closed nicecatch closed 1 month ago

nicecatch commented 1 month ago

Describe the bug I cannot seem to be able to count results when a fulltext search is made against an aggregation query

Type definitions

const typeDefs = gql`
  type Person
    @fulltext(
      indexes: [
        {
          name: "personFullTextIndex"
          fields: ["firstName", "lastName", "nickname", "title", "companyName"]
        }
      ]
    ) {
    id: ID! @id

    firstName: String
    lastName: String
    nickname: String

    title: String
    companyName: String

    region: String
}
`

To Reproduce

    const where: PersonWhere = {
      region_IN: ["North America"],
    };

    const fulltext = {
      personFullTextIndex: {
        phrase: "test",
      },
    };

    const total = await Person.aggregate({
      where,
      aggregate: {
        count: true,
      },
    });

    const totalAggregate = await Person.aggregate({
      where,
      fulltext,
      aggregate: {
        count: true,
      },
    });

    console.log("total", total);
    console.log("totalAggregate", totalAggregate);

They both returns the same total

Expected behavior I should get different values

Screenshots These are the 2 queries generated by the libraries

image
image

The second query has the $fulltext param but the variable is not passed

System (please complete the following information):

  "dependencies": {
    "@neo4j/graphql-ogm": "^5.4.5",
    "graphql": "^16.9.0",
    "graphql-tag": "^2.12.6",
    "neo4j-driver": "^5.22.0",
  },

Additional context Running a Person.find applies where and fulltext correctly to the query

neo4j-team-graphql commented 1 month ago

Many thanks for raising this bug report @nicecatch. :bug: We will now attempt to reproduce the bug based on the steps you have provided.

Please ensure that you've provided the necessary information for a minimal reproduction, including but not limited to:

If you have a support agreement with Neo4j, please link this GitHub issue to a new or existing Zendesk ticket.

Thanks again! :pray: