-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Making field property accessible after definition #87
Comments
👍 that'd be great! Maybe you could update the default resolve proc to check for a property? (or maybe that's a waste of time at runtime?) |
At first I didn't want to have the proc do the check, but then So I'm going to have the proc do the check. I don't think performance would be affected much, especially on ruby 2.x. |
Hmm, after making the changes, I realized I could've re-created the resolver proc when property is reassigned, instead of checking inside the proc. Not sure it's worth the effort to change it though. |
When defining a field, you can specify a property name, which gets called on the backing object during resolve:
However, it seems like the property isn't accessible on the
GraphQL::Field
object; it's wrapped inside the resolver lambda inGraphQL::DefinitionHelpers::DefinedByConfig::DefinitionConfig
:Is there interest in storing this to an instance variable and exposing a getter?
My use case is to access the mappings in a mutation which needs to do a reverse mapping, to set attributes on an ActiveRecord model. E.g. the mutation receives a
createdBy
argument and has to callrecord.created_by = input_value
. If there's a better way to do this, let me know.The text was updated successfully, but these errors were encountered: