-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access data from resolvers from previous node #128
Comments
Workaround found: I'm hacking the |
I would say you should try to avoid structure like this. And have each resolver to be able to work on it's own. Example below would be how I would do it in a non document database: data class UserProfile(val id: Int, val nickname: String)
data class UserContact(val userProfileId: Int, val discord: ContactField?, val skype: ContactField?, val ...)
data class ContactField(val value: String, val visibility: ContactVisibility)
...
query("getProfile") {
resolver { -> UserProfile(1, "jeggy") }
}
type<UserProfile> {
property<UserContact>("contact") {
resolver { userProfile -> service.loadContactById(userProfile.id) }
}
}
type<UserContact> {
property<ContactField?>("discord") {
resolver { contact ->
val requester = ctx.get<UserProfile>()
contact.discord?.takeIf {
it.visibility.canView(service.loadUserProfileById(contact.userProfileId), requester?.uid)
}
}
}
} But ofcourse you are using mongo and kmongo (which I have very little experience with). It will probably be hard to change your data structure to have all the information needed without the need of knowing who the grandparent resolver returned. |
But you how given scenarios for two new features that could be nice to have in KGraphQL, which are:
..
property<List<String>>("requestedFields") {
resolver { contact, ctx: Context, node: Execution.Node ->
node.getFields()
}
} |
Hello, I don't know if I'm doing something wrong, but I'd like to access the data resolved in the previous nodes of an execution.
I'm sharing a schema to help demonstrate:
Let's say I want to, in the resolver of
root (UserProfile) > contact > discord
make checks that will need to use the data available in the root node (check if two users are friends to make the data available or null). How could I do that?Thank you so much, great framework btw
The text was updated successfully, but these errors were encountered: