Skip to content
This repository was archived by the owner on Sep 3, 2021. It is now read-only.

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

Open
Phylodome opened this issue Jul 28, 2020 · 2 comments
Open

Comments

@Phylodome
Copy link

Phylodome commented Jul 28, 2020

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 Phylodome changed the title [BUG] Property Capable Relations Omit "first / offset / orderBy" Parameters Property Capable Relations Omit "first / offset / orderBy" Parameters Jul 28, 2020
@Phylodome Phylodome changed the title Property Capable Relations Omit "first / offset / orderBy" Parameters Property Capable Relations Lack "orderBy" Parameters for "To" Type Jul 28, 2020
@Phylodome
Copy link
Author

Phylodome commented Jul 29, 2020

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
Copy link
Collaborator

#608

# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants