rustgraphqljuniper

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


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

QueryRoot showcase of field name

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


Solution

  • 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.