Skip to content

Allow argument documentation  #525

Closed
@bryanburgers

Description

@bryanburgers

Is your feature request related to a problem? Please describe.

I like to provide clear documentation to my end users about everything in the schema, and this includes arguments.

Describe the solution you'd like

As of Rust 1.39, attributes are allowed on parameters. rust-lang/rfcs#2565.

I would like to see these used to provide documentation for arguments.

#[juniper::object(Context = Context)]
impl QueryRoot {
    #[doc = "Ability to document the endpoint already exists"]
    fn some_endpoint(
        context: &Context,
        #[doc = "Ability to document arguments would be awesome"]
        id: ID,
        #[doc = "Only include items in one of these states. Defaults to all states."]
        states: Option<Vec<StateInput>>
    ) -> SomeObject {
        todo!()
    }
}

Describe alternatives you've considered

We don't need to use #[doc = ""]. We could also use a custom attribute.

Additional context

Documenting arguments is common. For example, on the GitHub v4 API, everything considered a "Connection" has its arguments clearly documented.

#334 seems to suggest that this works. However, I can't seem to get it to work. Possibly it doesn't work in #[juniper::object] macros?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementImprovement of existing features or bugfix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions