Skip to content

Cannot use lifetime in impl blocks #1050

Closed
@ClementNerma

Description

@ClementNerma

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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingobsoleteThis issue is not relevant anymore

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions