-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
questionFurther information is requestedFurther information is requested
Description
I have a model that has a one to many relationship. Franchises to Posts. Franchises can have many posts, but a post can only have on franchise. This works fine using just the schema directives, but I try to do anything to scope it down using a where clause a custom resolver I'm always returned one result and I can't retrieve any of it's fields beyond id even if I remove my custom where clause. I've tried removing pagination directives but that only works if I remove the custom resolver.
Here's my schema
type Franchise @model(table: "franchises", pk: "id") {
id: ID!
name: String!
slug: String!
posts: [Post!]!
@relate(
on: [{ from: "id", to: "franchise_id" }]
pagination: OFFSET
)
@many
@paginate
}
type Post @model(table: "posts", pk: "id") {
id: ID!
slug: String!
title: String!
status: String!
franchise: Franchise
@relate(
on: { from: "franchise_id", to: "id" }
)
}Here's my resolver:
Franchise: {
async posts(parent, args, ctx, info) {
const whereClause = {
posts: {
status: { equal: 'published' },
}
}
return client.models.Franchise
.paginate()
.selectAll()
.where(whereClause as any)
.resolveInfo(info)
.execute()
},
},danielrearden
Metadata
Metadata
Assignees
Labels
questionFurther information is requestedFurther information is requested