Allow attribute to be used, but not to show up in the schema.#157
Conversation
|
Let me know if you want a PR for docs? |
richmolj
left a comment
There was a problem hiding this comment.
Great work @zeisler and thanks for this PR ❤️
This seems mergeable as-is, but want to note the scenario where we hide based on functionality rather than attribute. Something like:
attribute :foo, :string, schema: false
sort :foo, schema: trueNot strictly necessary, but something to think about. Up to you.
Something for the docs would be great - ideally there is a separate "Schema" section of the docs where we could put this, but I haven't had time to write that yet. Where would this have been most helpful for you?
| def sorts(resource) | ||
| {}.tap do |s| | ||
| resource.sorts.each_pair do |name, sort| | ||
| next unless resource.attributes[name][:schema] |
There was a problem hiding this comment.
This seems fine to me, unless you can envision a scenario where we allow something like the sort in the schema but not filtering/reading/etc.
There was a problem hiding this comment.
My only use case is that the whole attribute with it's sorting and filtering be hidden. My current project has a table with dynamic columns that changes with customer and year to year. So they are not relevant or available in different contexts. The place where this is hurting is in tests where I create test data that gets added to the schema, which never makes sense in production.
|
|
||
| attribute :first_name, :string, description: "The employee's first name" | ||
|
|
||
| attribute :hidden_attribute, :string, schema: false |
There was a problem hiding this comment.
I know we have the diff spec, but should probably be one here too that flips the boolean and asserts it's now present.
| it { is_expected.to eq([]) } | ||
| end | ||
|
|
||
| context "when attribute goes schema true to false" do |
c909d2b to
d78dec7
Compare
|
A schema section does seem helpful in general, but I would go looking for this flag in the resource concepts section. Here what I came up with graphiti-api/graphiti-api.github.io#12 |
|
I think this looks great! @zeisler if you could please add to |
Using attribute option `schema: false`. This option is default true and is not effected by `only` and `except` options.
d78dec7 to
c42e4ba
Compare
|
@richmolj changelog added. |
|
Awesome, well done @zeisler |
Using attribute option
schema: false.This option is default true and is not effected by
onlyandexceptoptions.