-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Investigate having support for union #10
Conversation
Build failure is related to needing to first declare the |
have you thought about any other option? I think we could go with that if we're not able to come up with something else. |
public final class UnionTypeBuilder<Type> { | ||
public var description: String? = nil | ||
public var resolveType: GraphQLTypeResolve? = nil | ||
public var types: [Any.Type] = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried using [Type.Type]
here (and in the union<Type>
function members
arguments) in an attempt to make it a bit more type safe however I was then unable to actually produce any code that would compile without errors like... Cannot convert value of type ... to expected argument type '[_.Type]'
I toyed with using enums to define the union but this resulted in more complication both with the implementation and on the call side. The marker protocol approach seemed the most elegant. Open to other suggestions however. |
CI is not passing due to some ACL issues.. can you please fix it? 😊 |
By the way, merged and tagged |
NICE™. CI is passing. think it's ready to merge? |
I think so. 😀 |
Codecov Report
@@ Coverage Diff @@
## master #10 +/- ##
==========================================
+ Coverage 82.69% 83.34% +0.64%
==========================================
Files 13 13
Lines 1745 1855 +110
==========================================
+ Hits 1443 1546 +103
- Misses 302 309 +7
Continue to review full report at Codecov.
|
Following up my own question in #9. I'm currently trying to think of the cleanest way to add union support to Graphiti.
This PR enables union support by way of a marker protocol. Usage is something like the following (trying to stick to the StarWars example)...
I wasn't able to figure out a way to validate that the types provided in
union.types
implement theDroidAndPlanetUnion
protocol.Tests etc. can follow should we agree on the way forward.