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
609 stars 148 forks source link

Property Capable Relations Lack "orderBy" Parameters for "To" Type #488

Open Phylodome opened 4 years ago

Phylodome commented 4 years ago

As of 2.15.0, specifying a type containing an inline @relation directive, like so:

type Movie {
  title: String
  year: Int
  genres: [Genre] @relation(name: "IN_GENRE", direction: "OUT")
}

Will generate an augmented type like:

type Movie {
  title: String
  year: Int
  genres(
    first: Int
    offset: Int
    orderBy: [_GenreOrdering]
    filter: _GenreFilter
  ): [Genre]
}

But specifying the relation as its own property-containing type, like so:

type Movie {
  title: String
  year: Int
  genres: [GenreRelation]
}

type GenreRelation {
  from: Movie
  to: Genre
  type: String
}

Appears to lose the orderBy functionality with respect to the targeted node type (here, Genre), and only generates:

type Movie {
  title: String
  year: Int
  genres( ### <-- !!! No `Genre` orderBy at relation-level, only works for relation properties !!! 
    first: Int
    offset: Int
    orderBy: [_MovieGenreRelationOrdering]
    filter: _MovieGenreRelationFilter
  ): [_MovieGenreRelation]
}

Where _MovieGenreRelationOrdering only provides the capacity to orderBy the properties of the relation itself (above, type_asc and type_desc), but does not provide the ability to orderBy any properties of the relationally targeted Genre type.

Additionally, the resulting _MovieGenreRelation contains no parameters on the targeted Genre key, so AFAICT filtering can't be accomplished at this level, either.

Is this by design? Forcing a tradeoff between a relation's capacity to contain properties and its capacity to order the related target nodes dramatically limits architectural flexibility, and appears to force the splitting into separate queries of any property-containing relations that require filtering / ordering.

Phylodome commented 4 years ago

In theory, this test, as described in #481, should cover this case.

Yet in practice when I attempt to structure my queries using this fragment-based approach, I do not see any of the properties from the targeted type included in the relation's orderBy parameter, as described above.

michaeldgraham commented 3 years ago

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