You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interface(:notification)dofield:id,non_null(:id)# a bunch of other fields with resolver functions that resolve the same for every interface implementationend
And 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.
nodeobject(:notification_about_something_specific)dointerface:notificationimport_fields:notification# plus specific fields for this notification typeend
And 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?
The text was updated successfully, but these errors were encountered:
interfaceRevision {
version: Int!createdAt: DateTime!
}
interfaceNode {
"The id of the object."id: ID!
}
typeUserRevisionimplementsRevision&Node {
"The id of the object."id: ID!"The ID of an object"id: ID!version: Int!createdAt: DateTime!role: UserRole!
}
typeUserRevisionEdge {
cursor: Stringnode: UserRevision
}
typeUserRevisionConnection {
pageInfo: PageInfo!edges: [UserRevisionEdge]
}
Honestly, I didn't realize people were using import_fields on interfaces. I can see how it is sometimes convenient but the moment you need a custom resolver things can get a bit weird. We can work to make import_fields deduplicate, but there are trade offs. The duplicate ID thing without an explicit :id field is weird, will look into it.
I defined an interface like this:
And there's a connection:
And 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.And this basically works as expected when using the API. However, there is one problem: By using both
node
andimport_fields
, two:id
field definitions are created. And those two ID fields will end up in the SDL file generated withmix 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 theid
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 existingid
field instead of just adding one?The text was updated successfully, but these errors were encountered: