Skip to content

Cannot use lifetime in impl blocks #1050

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

Closed
ClementNerma opened this issue Mar 30, 2022 · 1 comment
Closed

Cannot use lifetime in impl blocks #1050

ClementNerma opened this issue Mar 30, 2022 · 1 comment
Assignees
Labels
bug Something isn't working obsolete This issue is not relevant anymore
Milestone

Comments

@ClementNerma
Copy link

ClementNerma commented Mar 30, 2022

When writing an impl block with the #[graphql_object] attribute, declared lifetimes cannot be used in the return type. Example:

pub struct IndexGraph;

#[graphql_object(context = GraphQLContext)]
impl IndexGraph {
    async fn fingerprint<'c>(&self, context: &'c GraphQLContext) -> &'c str {
        context.index.fingerprint.as_str()
    }
}

I get the following error: use of undeclared lifetime name 'c in the return type.

The document states to use this syntax for lifetimes so I wonder if it's a bug or if there is another way to do this?

Using Juniper 0.15.9.

@ClementNerma ClementNerma added bug Something isn't working needs-triage labels Mar 30, 2022
@tyranron tyranron self-assigned this Mar 31, 2022
@tyranron tyranron added obsolete This issue is not relevant anymore and removed needs-triage labels Mar 31, 2022
@tyranron
Copy link
Member

tyranron commented Mar 31, 2022

@ClementNerma this is not possible in juniper 0.15 due to how #[graphql_object] is desugared. This, however, is fixed in the current master (see #971) and will be released in 0.16, once we complete all the necessities for the release (no ETAs can be given, though).

@tyranron tyranron added this to the 0.16.0 milestone May 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working obsolete This issue is not relevant anymore
Projects
None yet
Development

No branches or pull requests

2 participants