Where
class FindRecord < GraphQL::Function
...
argument :id, !types.ID
...
end
this variation of a field definition within a GraphQL::ObjectType.define
block works without error:
field 'd1', DirectoryType, function: FindRecord.new(:directory)
But for the same query this fails with the error message "Field 'd2' doesn't accept argument 'id'":
field 'd2', DirectoryType do
function FindRecord.new(:directory)
end
After those fields are defined, for both d1
and d2
the value of target.fields['d?'].function
is the same (with different object ids). But it looks like in the block version the function doesn't get applied to the field.
It also doesn't work when I skip the field
helper and define the field like this:
target.fields[name] = GraphQL::Field.define {
...
function FindRecord.new(:directory)
...
}
Am I calling the function method wrong? Any suggestions appreciated.