How can I set the name of fields in my schema using Juniper and Rust?

How can I set the name of fields in my schema using Juniper and Rust?


0

I’m currently developing a GQL API in Rust using Actix and Juniper.

actix = "0.13.0"
juniper = "0.15.11"

I’ve managed to create a working environment without issues, however I’ve noticed that Juniper is automatically renaming my Query fields.

The code below generates a new field under my QueryRoot which should be named "list_shows"

impl ShowQueries {
    pub async fn list_shows(name: String, context: &Context) -> FieldResult<Show> {
        ...
    }
}

However in my Schema it appears as listShows

How can I set the name of fields in my schema using Juniper and Rust?

Is there any macro or setting or something I could touch in Juniper to keep the field name as list_shows instead?

Thank you very much

Share

1 Answer
1

Reset to default


0

I found it in their documentation finally it was just poorly placed to figure it out.
https://graphql-rust.github.io/juniper/master/types/objects/complex_fields.html#description-renaming-and-deprecation

#[juniper::graphql_object(Context=Context)]
impl ShowQueries {
    #[graphql(name="list_shows", description="List all shows or a single show.")]
    pub async fn list_shows(name: String, context: &Context) -> FieldResult<Show> {
        ...
    }
}

Hope it helps someone in the future.

Share



Not the answer you're looking for? Browse other questions tagged

or ask your own question.

Leave a Reply

Your email address will not be published. Required fields are marked *