Skip to content
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

Allow argument documentation #525

Closed
bryanburgers opened this issue Feb 6, 2020 · 3 comments · Fixed by #971
Closed

Allow argument documentation #525

bryanburgers opened this issue Feb 6, 2020 · 3 comments · Fixed by #971
Labels
enhancement Improvement of existing features or bugfix

Comments

@bryanburgers
Copy link

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?

@bryanburgers bryanburgers added the enhancement Improvement of existing features or bugfix label Feb 6, 2020
@LegNeato
Copy link
Member

I believe this will be enabled by #441, right @davidpdrsn ?

@davidpdrsn
Copy link
Contributor

Not sure. I will add it as a todo to look into.

@Victor-Savu
Copy link
Contributor

Victor-Savu commented Feb 28, 2020

Using attributes to document parametrs would be great! However, it should not hold back #441. If I am not mistaken, it is a backwards-compatible feature, so it can be added in later without breaking any of the code that might already be relying on #441. @davidpdrsn you are the best parson to decide on that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants