dry-graphql
dry-graphql copied to clipboard
DuplicateTypeNamesError if graphql_name is not given
Hello, I use dry-graphql for it's purpose, turning my dry structs to graphql type. Here is one of my types:
module Types
module Events
class TitleEmittedType < ::Events::TitleEmitted.graphql_type(skip: SKIPPED_ATTRIBUTES)
graphql_name 'TitleEmitted'
description 'Event for emitted title'
end
end
end
With it's struct:
module Events
class TitleEmitted < MovementEvent
attribute :id, Types::UUID
attribute :label, Types::String
attribute :quantity, Types::Integer
attribute? :bucket_id, Types::Integer.optional
attribute? :bucket_metadata, Types::BucketMetadata.optional
attribute :register_id, Types::Integer
attribute :right_id, Types::Integer
attribute? :special_right_ids, Types::Array.of(Types::Integer).default([].freeze)
attribute? :voting_rights, Types::Integer.optional
attribute? :financial_rights, Types::Integer.optional
attribute :nature, Types::String
attribute? :source_title_id, Types::UUID.optional
attribute? :source_bucket_id, Types::Integer.optional
attribute? :source_label, Types::String.optional
attribute :state, Domain::Types::TitleState
attribute :sub_titles, Types::Array.of(Types::EventTitleInput)
def destination_bucket_ids
super + sub_titles.pluck(:bucket_id)
end
def destination_title_ids
super + sub_titles.pluck(:title_id)
end
end
end
This config worked great until I updated rubocop-graphql, it gave me this:
GraphQL/GraphqlName: graphql_name should be specified only for overrides.
class TitleEmittedType < ::Events::TitleEmitted.graphql_type(skip: SKIPPED_ATTRIBUTES)
So I removed the graphql_name and now I have this errors when generating the schema:
GraphQL::Schema::DuplicateTypeNamesError:
Multiple definitions for `Events__titleemitted`. Previously found DryGraphQLGeneratedTypeForEvents::TitleEmitted (Class), then found DryGraphQLGeneratedTypeForEvents::TitleEmitted (Class) at Mutation.createGroup.group.registers.edges.node.movements.edges.node.event.possible_types.userMetadata
I think this might be related: https://github.com/rmosolgo/graphql-ruby/issues/3949
Hope you can help !