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

A way to add descriptions to arguments #334

Closed
peitalin opened this issue Mar 18, 2019 · 1 comment
Closed

A way to add descriptions to arguments #334

peitalin opened this issue Mar 18, 2019 · 1 comment
Labels
enhancement Improvement of existing features or bugfix

Comments

@peitalin
Copy link

peitalin commented Mar 18, 2019

Is your feature request related to a problem? Please describe.
Is there a way to add descriptions for arguments?

Describe the solution you'd like
A way to add descriptions to arguments, something like this in the graphql_object! macro:

    field items(
        &executor,
        #[graphql(description = "first n items")]
        first: i32,
        #[graphql(description = "last n items")]
        last: i32,
    ) -> FieldResult<Items> {
        ...
    }

Or:

#[derive(GraphQLInputObject)]
#[graphql(description = "first n items")]
type First = i32;

Which is used in the resolver as:

field item(&executor, first: First, last: Last) -> FieldResult<Item> {
    ...
}

Describe alternatives you've considered
I have looked into #[derive(GraphQLInputObject)] but that seems only for passing structs as arguments.

@peitalin peitalin added the enhancement Improvement of existing features or bugfix label Mar 18, 2019
@peitalin
Copy link
Author

peitalin commented Mar 18, 2019

I just realised you can do this with doc strings:

field items(
    &executor,
    /// first n items
    first: i32,
    /// last n items
    last: i32,
) -> FieldResult<Items> {
    ...
}

Or more generally:

field items(
    &executor
    #[doc = "Argument description"]
    arg_name: ArgType
    arg_name: ArgType as "Argument description"
    arg_name = default_value: ArgType as "Argument description"
) -> FieldResult<Items> {
    ...
}

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

No branches or pull requests

1 participant