I am looking to do something similar to what is done in the graphql tutorial: https://graphql.org/learn/queries/#arguments
I want to pass feet/meters to a scaler field to transform the result that is returned.
{
human(id: "1000") {
name
height(unit: FOOT)
}
}
I can't figure out how to do that in ruby using graphql-ruby.
I currently have a type that looks like:
class Types::Human < Types::BaseObject
field :id, ID, null: false
field :height, Int, null: true do
argument :unit, String, required: false
end
def height(unit: nil)
#what do I do here to access the current value of height so I can use unit to transform the result?
end
end
I have found that the resolver method (height) is called for every instance that is returned... but I don't know how to access the current value.
Thanks