-
Notifications
You must be signed in to change notification settings - Fork 437
Infer graphql "deprecation" from #[deprecated(note = "...")] in derive (and macros) #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer graphql "deprecation" from #[deprecated(note = "...")] in derive (and macros) #269
Conversation
Codecov Report
@@ Coverage Diff @@
## master #269 +/- ##
==========================================
+ Coverage 88.99% 89.05% +0.05%
==========================================
Files 102 102
Lines 20678 21039 +361
==========================================
+ Hits 18403 18736 +333
- Misses 2275 2303 +28
Continue to review full report at Codecov.
|
LegNeato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! 🍻 It looks great ❤️ . One thing I would like to see supported is the bare #[deprecated] form, as one could reasonably expect it to work and I don't believe the GraphQL spec says a reason is required (https://facebook.github.io/graphql/June2018/#sec-Deprecation). I did similar stuff in graphql-client if you want to take a look.
Also, please add an entry to the changelog.
|
Oh; I didn't realize the reason was optional; I'll definitely update to support the bare deprecation |
|
@LegNeato: Changelog, docs, etc added--- build failure on Azure is only due to spurious network error. Can you have it retry? |
LegNeato
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making the changes so quickly! Would it be too much trouble to split the doc parsing into a separate PR? It's hard to review with both the deprecation changes and doc changes in one PR.
| } | ||
| if let Some(AttributeValue::String(val)) = | ||
| keyed_item_value(&item, "deprecated", AttributeValidation::String) | ||
| keyed_item_value(&item, "deprecation", AttributeValidation::String) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be deprecated, right? And if so, it looks like repeated code and can be removed, as the next block is doing match keyed_item_value(&item, "deprecated", AttributeValidation::String
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partially yes.
This check appears to be unnecessary for backwards compatibility, however I believe the reason that the line is in the EnumVariantAttrs impl is because I was using the same code block to handle it for both that and ObjectFieldAttrs.
In the current version (specifically on master), the attribute name is inconsistent between enum variants which use deprecated and object fields which use deprecation.
This change, makes both support the same set of attributes in a backwards-compatible way. Happy to remove it if that is undesirable.
If the use of deprecation on object fields is itself considered deprecated, I can remove this one on EnumAttrs, and if desired can also remove the same one on ObjFieldAttrs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yeah. Sorry, forgot about that previous support.
Follow on to #194.
Derive
Updates the
GraphQLObjectandGraphQLEnumderives to use the first#[deprecated]annotation with anote = ...to supply the deprecation text, which can still be overridden with#[graphql(deprecation = ...)]like in #195.Macros
Additionally, this PR adds support for
#[doc = ...]and#[deprecated(note = ...)]to thegraphql_object!andgraphql_interface!macros, which has some benefits:Lets your
field name(args...)line-up so that they're easier to scan (even with a deprecation)`Allows mutliple doc strings be combined akin to the collapse_docs behavior.
(including any
const SOME_DESC: &'static strif you want w/#[doc = SOME_DESC])Makes it easier to refactor a
#[derive(GraphQLObject)]into agraphql_object!, e.g. a contrived example