1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
# frozen_string_literal: true
module GraphQL
class Schema
class Member
module HasAstNode
def self.extended(child_cls)
super
child_cls.ast_node = nil
end
def inherited(child_cls)
super
child_cls.ast_node = nil
end
# If this schema was parsed from a `.graphql` file (or other SDL),
# this is the AST node that defined this part of the schema.
def ast_node(new_ast_node = nil)
if new_ast_node
@ast_node = new_ast_node
elsif defined?(@ast_node)
@ast_node
else
nil
end
end
attr_writer :ast_node
end
end
end
end
|