Alias A Model Method Or Field in a GraphQL Type
If you need to override the name of a model method or field in a GraphQL type, you can use the property
argument.
Let's say we have a model called Message:
class Message < ApplicationRecord
def bar
"bar"
end
end
We can then make an alias to the bar method by specifying a property in our MessageType:
Types::MessageType = GraphQL::ObjectType.define do
field :foo, types.String, property: :bar
end
Tweet