Inline filter documentation
datapimp opened this issue · comments
Jonathan Soeder commented
I'm working on my own library which subclasses mutations, and I am writing this to see if you would have any interest in merging this particular feature into the mutations gem itself. This will determine some aspects of my approach going forward
class UpdateBook < Mutations::Command
required do
desc "The title of the book"
string :title
optional do
desc "Tags for the book"
array :tags
end
end
end
This gives anyone the ability to generate documentation for the command's interface:
UpdateBook.interface_documentation
This produces (still a WIP)
{
required_inputs: ["name"],
optional_inputs: ["tags"],
schema: {
title: {
type: "string",
description: "The title of the book"
},
tags: {
type: "array",
description: "Tags for the book"
}
}
}
I have considered using just a description key in the options hash but think that this is not the optimal style of writing these kinds of things imo and it isn't inline with the rest of the conventions in my library