-
Notifications
You must be signed in to change notification settings - Fork 147
Interfaces - Handle multiple fragments. #270
Conversation
Eureka! @johnymontana I've also solved an issue when you query fields of a type that do not exist on the interface that the type implements. I've done this by passing the schemaType of the type of the fragment instead of the interface schemaType. Example: interface Person { type Man { then beard was not queryable before this fix. |
There are still several issues regarding to interfaces that have not been handled yet such as:
Currently just having working fragments is sufficient for my use case (so far) so I'll touch those if anyone requires them. |
…ad of only querying the 'headSelection'
Thanks @Pruxis! Would you mind adding a couple of tests showing some examples of what this fixes? We were envisioning interfaces making use of multiple labels in the database. For example:
would correspond in nodes in the database |
Codecov Report
@@ Coverage Diff @@
## master #270 +/- ##
=======================================
Coverage 94.47% 94.47%
=======================================
Files 4 4
Lines 326 326
=======================================
Hits 308 308
Misses 18 18 Continue to review full report at Codecov.
|
I'd just like to chime in that I do in fact use multiple labels and need this fix to support them. I really appreciate the work that has been done so far. Also, not every node pointed to with the given relationship type would be candidates for the field. Some can be a completely different type that doesn't implement the interface. These are available on a different field referencing a different interface, but using the same relationship type. Does the default resolver handle this case? E.g.
...and where the nodes are labeled :A:B, :A:C, :X:Y, or :X:Z. Possibly with other labels as well. |
In this PR I have changed how the fragments are handled a bit.
Instead of relying on the node matching I would match all nodes that are related with the relation you are fetching. And pass the label as a FRAGMENT_TYPE so the default resolver can do the rest.
This will support default interface queries & multiple fragments and will still return the correct type.
However if your graph would contain multiple labels for a node we would have to pass the entire array of labels and check that instead in the default resolver, I didn't do that yet but if core contributors would like to see this "improvement" I can surely add this here.
I'm quite blocked by this PR so it would be great if there is some feedback here that we can solve this issue as fast as possible.
Looking forward to contribute more to this package as we started to rely heavily on neo4j & apollo.