-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Keywords in meta path positions cause parsing errors #1458
Comments
I think this is behaving correctly. macro_rules! meta {
($m:meta) => {};
}
meta!(type = "hi"); error: expected identifier, found keyword `type`
--> src/lib.rs:5:7
|
5 | meta!(type = "hi");
| ^^^^ expected identifier, found keyword |
The inconsistency noted here, where the meta parses fine if it's |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [async-graphql](https://github.com/async-graphql/async-graphql) | dependencies | major | `5.0.10` -> `6.0.4` | | [async-graphql-axum](https://github.com/async-graphql/async-graphql) | dependencies | major | `5.0.10` -> `6.0.4` | --- ### Release Notes <details> <summary>async-graphql/async-graphql (async-graphql)</summary> ### [`v6.0.4`](https://github.com/async-graphql/async-graphql/blob/HEAD/CHANGELOG.md#604-2023-08-18) - Parse "repeatable" in directive definitions. [#​1336](https://github.com/async-graphql/async-graphql/pull/1336) - add support `multipart/mixed` request. [#​1348](https://github.com/async-graphql/async-graphql/issues/1348) - async-graphql-actix-web: add `GraphQL` handler. - async-graphql-axum: add `GraphQL` service. ### [`v6.0.3`](https://github.com/async-graphql/async-graphql/blob/HEAD/CHANGELOG.md#603-2023-08-15) - dynamic: fix the error that some methods of `XXXAccessor` return reference lifetimes that are smaller than expected. - dynamic: no longer throws an error if the Query object does not contain any fields but the schema contains entities. - chore: make accessors public and reexport indexmap [#​1329](https://github.com/async-graphql/async-graphql/pull/1329) - feat: added `OutputType` implementation for `std::sync::Weak` [#​1334](https://github.com/async-graphql/async-graphql/pull/1334) ### [`v6.0.1`](https://github.com/async-graphql/async-graphql/blob/HEAD/CHANGELOG.md#601-2023-08-02) - dynamic: remove `TypeRefInnner` - update MSRV to `1.67.0` ### [`v6.0.0`](https://github.com/async-graphql/async-graphql/blob/HEAD/CHANGELOG.md#600-2023-07-29) - Bump `syn` from `1.0` to `2.0` - Bump `darling` from `0.14` to `0.20` - Bump `indexmap` from `1.6.2` to `2` - Attributes `guard`, `process_with`, `complexity` support expression or string as value [#​1295](https://github.com/async-graphql/async-graphql/issues/1295) - Schema (type) level directive support with optional support of federation composeDirective [#​1308](https://github.com/async-graphql/async-graphql/pull/1308) - Add support for generic structs derriving InputObject and SimpleObject [#​1313](https://github.com/async-graphql/async-graphql/pull/1313) - chore: trim up some unnecessary code [#​1324](https://github.com/async-graphql/async-graphql/pull/1324) - Adds `Dataloader::get_cached_values` method to the dataloader cache so that callers can access the contents of the cache without knowing the keys. [#​1326](https://github.com/async-graphql/async-graphql/pull/1326) #### Breaking Changes - Since `syn 2.0` no longer supports keywords as meta path, rename the parameter used to specify interface field types from `type` to `ty`. [https://github.com/dtolnay/syn/issues/1458](https://github.com/dtolnay/syn/issues/1458) [https://github.com/TedDriggs/darling/issues/238](https://github.com/TedDriggs/darling/issues/238)/238 ```rust #[derive(Interface)] #[graphql(field(name = "id", ty = "&i32"))] // rename from type to ty enum Node { MyObj(MyObj), } ``` - Change the parameter `location` of the macro `Directive` to *PascalCase* ```rust // #[Directive(location = "field")] #[Directive(location = "Field")] pub fn lowercase() -> impl CustomDirective { LowercaseDirective } ``` </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Enabled. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about these updates again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/apollographql/subgraph-template-rust-async-graphql). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi42OC4xIiwidXBkYXRlZEluVmVyIjoiMzYuNjguMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
`syn2` doesn't allow to use keywords as part of `MetaItem` dtolnay/syn#1458 This is reason of renaming `type` to `ty`, which is breaking change
I would prefer not to add this. In macro_rules, the only intended use for $:meta is as Whether keys can be a keyword is not the only consideration. There is also the fact that |
Thanks for the explanation on this; it now makes more sense why For the
Aside: In the paragraph that follows, I'm going to use It'd be a pretty rough breaking change for I think it'd be really interesting to make this generic over what's allowed in the RHS position of |
I think it is not a matter of writing a smarter Parse impl — parsing an attribute's nested contents into any data structure without regard for what the keys mean is fundamentally problematic. For example, consider what you might do to parse |
That's a good example. I'm passionate about preserving the ease-of-use of Would your recommendation be that I think I can imagine a lot of |
Deriving a function that operates on I don't have a complete design with all of the signatures worked out, but following the handwritten ones in colin-kiegel/rust-derive-builder#310 would be a good guide. |
On syn 2.0.16, the following code produces an error:
This has caused issues for
darling
users (TedDriggs/darling#238) who are consuming meta items with names such astype
orpub
.I think the issue is here where the
impl Parse for Meta
,impl Parse for MetaList
andimpl Parse for MetaNameValue
all call out toPath::parse_mod_style
. Could there be a similar function that for parsing paths in thisMeta
context usesIdent::peek_any
so that keywords are allowed?The text was updated successfully, but these errors were encountered: