Closed williamluke4 closed 6 years ago
Hi @williamluke4 ,
Thanks heaps for reaching out and reporting that issue. I'll work on this asap.
I'll let you know when that's done.
Cheers,
Nic
Thanks @nicolasdao I was able to get it to work using __resolveType in the Unions resolver.
union User= Admin_User| Foo_User
exports.resolver = {
User:{
__resolveType(obj, context, info){
if(typeof obj.id === 'string'){
return 'Admin_User';
}
return 'Foo_User';
}
}
}
`
Hi @williamluke4 ,
You're completely right! Thanks a lot for this question and for answering it yourself 😍. I've just documented your feedback in the README.md to make it clearer to everybody.
In case you're interested, I've also open-sourced another project called graphql-s2s. It won't really help to manage unions, but it can make your schema definition more concise, readable and reusable. In a nutshell, it introduces the concept of inline inheritance, generic types and metadata. The feature that could help you with managing interfaces in your schema is the inheritance bit. You can check the documentation here.
Cheers,
Nic
Does schemaglue currently support graphql unions? Very helpful project thanks for all the work!