-
Notifications
You must be signed in to change notification settings - Fork 67
Open
Description
Hi,
I'm having issues creating a GraphQL schema with Graphiti containing a many-to-many relationship.
The setup is basically this :
let schema = try! Schema<Resolver, Request> {
Scalar(UUID.self)
Type(User.self) {
Field("id", at: \.id)
[ ... ]
// Users' groups (many-to-many relationship)
Field("groups", at: User.getGroups)
}
Type(Group.self){
Field("id", at: \.id)
[ ... ]
Field("users", at: Group.getUsers)
}
[ ... ]
}
I'm getting the error
Fatal error: 'try!' expression unexpectedly raised an error: Cannot use type "Array<Group>" for field "groups". Type does not map to a GraphQL type.
The problem seems that User
uses groups
before Group
is declared. Do you have a sample or some docs I didn't see how to pre-declare types in this scenario ?
Thank you
Metadata
Metadata
Assignees
Labels
No labels