Suppose we have Series and Episodes, and each Series has many Episodes:
type Query {
series: [Series!]! @paginate(defaultCount: 10)
series(id: ID @eq): Series @find
episodes: [Episode!]! @paginate(defaultCount: 10)
episode(id: ID @eq): Episode @find
}
type Series {
id: ID!
title: String!
episodes: [Episode]! @hasMany
plot: String!
}
type Episode {
id: ID!
title: String!
season: Int!
series: Series! @belongsTo
plot: String!
}
Everything works fine. We can query series and episodes and they are paginated.
The Lighthouse docs says we can also paginate relations by setting type
on the @hasMany
directive (https://lighthouse-php.com/master/api-reference/directives.html#hasmany) like so:
type Series {
id: ID!
title: String!
episodes: [Episode]! @hasMany(type: "paginator")
plot: String!
}
This works fine when querying series like this:
query series {
series {
paginatorInfo {
total
currentPage
hasMorePages
}
data {
title
episodes {
paginatorInfo {
total
currentPage
hasMorePages
}
data {
title
}
}
}
}
}
Series and their episodes each get paginated.
But now I can no longer query episodes directly:
query episodes {
episodes {
paginatorInfo {
total
currentPage
hasMorePages
}
data {
title
}
}
}
This returns the error No class 'EpisodePaginator' was found for directive 'paginate'"
What does that mean exactly, and how do I get the ability to paginate both related models and all models directly?
This was a bug and has been fixed in v4.8.1 https://github.com/nuwave/lighthouse/releases/tag/v4.8.1