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

Filter and Limit is not working on Child Nodes

Open Eddy08 opened this issue 2 years ago • 1 comments

GraphQL schema

type Parent{
     parent_id: String
     parent_name: String
    Parent_Child_Mapping:[Parent_Child_Mapping]
}
type Parent_Child_Mapping @relation (name: "Parent_Child_Mapping", from :"Parent", to: "Child"){
     Parent: Parent
    Child: Child
    edgeDetails: String
}
type Child{
     child_id: String
     Parent_Child_Mapping: [Parent_Child_Mapping]
}

GraphQL request

query:
           Parent(first:2) { 
                                        parent_id
                                       Parent_Child_Mapping(first:2){
                                                edgeDetails
                                                Child(first:2){
                                                   child_id
                                                  }
                                         }
                             }

Expected GraphQL response

Error :Missing Field:Validation error of type UnknownArgument:Unknown field argument firs @ 'Parent/Parent_Child_Mapping/Child'

Additional context In My Current Data there are multiple relationships between two nodes i.e One Parent Node with Multiple Parent_Child_Mapping with One Child Node. Limit and Filter should work on the Child Node but working only on Parent and Parent_Child_Mapping.

Eddy08 avatar Sep 07 '22 10:09 Eddy08

Hi @Eddy08, this is the expected behavior. In type Parent_Child_Mapping you have defined Parent and Child as singleton attributes so filter, first and offset arguments will not work because according to graphql-spec these arguments can be applied on List attributes. In this case if you want to apply filters on child node you can write your graphql as below

{ 
  Parent(first:2) { 
    parent_id
    Parent_Child_Mapping(first:2, filter: {Child: {child_id: "id-filter"}}) {
      edgeDetails
      Child {
        child_id
      }
    }
  }
}

AakashSorathiya avatar Mar 10 '23 13:03 AakashSorathiya