-
Notifications
You must be signed in to change notification settings - Fork 90
Description
I defined an interface like this:
interface(:notification) do
field :id, non_null(:id)
# a bunch of other fields with resolver functions that resolve the same for every interface implementation
endAnd there's a connection:
connection(node_type: :notification)
node object(:me) do
connection field :notifications, node_type: :notification do
resolve &Notification.list_my_notifications/2
end
endAnd then I'm defining the concrete implementation as a node object like this. And since I don't want to copy all the fields including the resolver functions to every interface implementation, I'm using import_fields to import them from the interface.
node object(:notification_about_something_specific) do
interface :notification
import_fields :notification
# plus specific fields for this notification type
endAnd this basically works as expected when using the API. However, there is one problem: By using both node and import_fields, two :id field definitions are created. And those two ID fields will end up in the SDL file generated with mix absinthe.schema.sdl, which then causes tools that read that file to return an error.
I'm not sure how to fix this. I can move all the field definitions to the interface implementations instead of using import_fields, but that kind of defeats the purpose of defining an interface. And I can remove the id field from the interface definition, so that only the implementations define it, but that seems logically wrong.
I wonder if it would make sense if the node macro overwrites any existing id field instead of just adding one?