wundergraph
wundergraph copied to clipboard
Unable to rename graphql entity
According to #8 and the commit here it should be possible to rename the graphql entity using #[wundergraph(graphql_name = "MyNewName")] however, it does not seem to work for me.
I change the name (trying to fix a pluralizatoin issue) but it has no effect.
Is it me missing a switch again, or an actual bug?
My code
use wundergraph::prelude::*;
table! {
addresses (id) {
id -> Int4,
address_line -> Varchar,
postal_code -> Varchar,
city -> Varchar,
country -> Varchar,
}
}
#[derive(Clone, Debug, Identifiable, Queryable, WundergraphEntity)]
#[wundergraph(graphql_name = "Addresses")] // <-- Trying to enforce this name that gets wrong in pluralization
#[table_name = "addresses"]
pub struct Address {
pub id: i32,
pub address_line: String,
pub postal_code: String,
pub city: String,
pub country: String
}
Result

The address entity is still wrongfully named Adresss with three s
This attribute controls only the name of that type if it's just from other types that use WundergraphEnitity. wundergraph::query_object has it's own set of attributes as requires to generate two different entities, one for the generic filter API and one for the primary key based access. See the documentation here. That said while rereading the documentation I've noticed that it is not clear that the #[wundergraph(graphql_name = "TheHero")] there only changes the pluralized name, while the singular name is the hard coded type name. (You could just use use YourType as Something; there to rename that field).
Leaving this open as reminder to fix the docs someday.