-
Notifications
You must be signed in to change notification settings - Fork 147
[Question/Suggestion] Autogeneration of Mutations for relations to Interface types #182
Comments
@wimklerkx Do you have a sharable working code? Or do you know if there is any official solution to this (other that what you've outlined above)? I have the exact same problem. I looked into to graphql-s2s but it is not useful for relations to interfaces. |
First, currently there is some work being done on this and on related 'interface' issues: In the meantime I have fiddled with the idea presented above, but abandoned it as I found myself picking the library apart and was limited by time constraints I found a way to keep going forward by customising all 'GET' queries and concat subqueries for all implementation types of an interface (by inspecting the schema object). But that's quite cumbersome and potentially slows things down. Another quirk then led to having to create schema unions for each interface, like this: All in all I would not advice to take this road, and I'm looking forward to a real solution :) |
Thanks @wimklerkx for your findings. |
Hi @johnymontana, are there any plans to support interfaced relations? As for the latest version, I see that the mutation queries are created, but produces the following error:
The above error is coming from the "movies" example code. Just thinking out loud; would it be possible to tell the query which type is going to be linked in the "to" input? For example;
|
question: What is the best practice for resolving Mutations for interfaced types?
Example schema:
The makeAugmentedSchema() function will autogenerate AddCreativeWorkResponsiblePerson and AddCreativeWorkPublicRepository mutations and resolvers.
But it will not autogenerate the AddCreativeWorkAuthor mutation and resolver.
——————————
So far I’ve come up with something along these lines:
But this feels quite cumbersome;
Plus: my schema has many interfaced types, some of which will also need relations to other interfaced/unioned types - adding another layer of complications
There must be a better way
—————————————
Could, maybe, a solution be found on the basis of this proposal?:
If a node would carry the Interface (or Union) label(s) as well, it might be possible to autogenerate the Add/Update/Delete resolvers for relations to/from Interface/Union types.
This could only work if the identifier ID is globally unique, as proposed in the GraphQL specification.
As it would be able to autogenerate an AddCreativeWorkAuthor mutation resolver with a cypher query like this:
The text was updated successfully, but these errors were encountered: