has_nested_graphql_name.rb 473 B

123456789101112131415161718
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. module Gql::Concerns::HasNestedGraphqlName
  3. extend ActiveSupport::Concern
  4. included do
  5. def self.inherited(subclass)
  6. super
  7. return if !subclass.name
  8. subclass.graphql_name(subclass.name.sub(%r{Gql::[^:]+::}, '').gsub('::', '').delete_prefix('Input').sub(%r{Type\Z}, ''))
  9. end
  10. def self.graphql_field_name
  11. graphql_name.camelize(:lower).to_sym
  12. end
  13. end
  14. end