Closed
Description
Ideally I'd like to be able to do
pub trait Node {
fn id(&self) -> &Uuid;
}
pub struct Queue {
pub id: Uuid,
pub name: String,
...
}
impl Node for Queue {
fn id(&self) -> &Uuid {
&self.id
}
}
graphql_interface!(<'a> &'a Node: Context as "Node" |&self| {
field id() -> &Uuid {
self.id()
}
instance_resolvers: |&context| { ... }
});
graphql_object!(Queue: Context |&self| {
interfaces: [&Node]
field name() -> &str {
&self.name
}
});
And get
scalar Uuid
interface Node {
id: Uuid
}
type Queue implements Node {
id: Uuid
name: String
}
Currently you can get an invalid schema if you forget to implement the id
field on the Queue
object.
Python's Graphene works in this way http://docs.graphene-python.org/en/latest/types/interfaces/
I realise this wouldn't be a very backwards-compatible change
Thoughts?