Method: GraphQL::Schema::Interface::DefinitionMethods#included
- Defined in:
- lib/graphql/schema/interface.rb
#included(child_class) ⇒ Object
Here's the tricky part. Make sure behavior keeps making its way down the inheritance chain.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/graphql/schema/interface.rb', line 50 def included(child_class) if !child_class.is_a?(Class) # In this case, it's been included into another interface. # This is how interface inheritance is implemented # We need this before we can call `own_interfaces` child_class.extend(Schema::Interface::DefinitionMethods) child_class.type_membership_class(self.type_membership_class) child_class.ancestors.reverse_each do |ancestor| if ancestor.const_defined?(:DefinitionMethods) && ancestor != child_class child_class.extend(ancestor::DefinitionMethods) end end child_class.introspection(introspection) child_class.description(description) child_class.comment(nil) # If interfaces are mixed into each other, only define this class once if !child_class.const_defined?(:UnresolvedTypeError, false) add_unresolved_type_error(child_class) end elsif child_class < GraphQL::Schema::Object # This is being included into an object type, make sure it's using `implements(...)` backtrace_line = caller_locations(0, 10).find do |location| location.base_label == "implements" && location.path.end_with?("schema/member/has_interfaces.rb") end if !backtrace_line raise "Attach interfaces using `implements(#{self})`, not `include(#{self})`" end end super end |