Hi, I would like to be able to use some simple types as both input and object, such as:
#[derive(GraphQLObject, GraphQLInputObject)]
pub struct Coords {
pub lat: f64,
pub lng: f64,
}
But if I try so, I get:
error[E0119]: conflicting implementations of trait `juniper::GraphQLType` for type `Coords`:
59 | #[derive(Clone, Default, Debug, Serialize, Deserialize, GraphQLObject, GraphQLInputObject)]
| ^^^^^^^^^^^^^ ------------------ first implementation here
| |
| conflicting implementation for `Location`
That makes sense because Juniper will try to make the schema type name match the struct name, but I would like to be able to do something like:
#[derive(GraphQLObject, GraphQLInputObject)]
#[graphql_input(name="CoordinateInput", description="An input for a position on the globe")]
#[graphql_object(name="Coordinate", description="A position on the globe")]
pub struct Coords {
pub lat: f64,
pub lng: f64,
}
Thoughts?
That's not possible with the current trait system, since GraphQLType can only be implemented once.
Also, while sometimes annoying, I really value the strict separation between input and output types that GraphQL enforces and I think it leads to good separation in code also.
This was discussed in another issue too but I can't find it right now.