class GraphQL::Schema::Finder
Find schema members using string paths
Examples
Example: Finding object types
MySchema.find("SomeObjectType")
Example: Finding fields
MySchema.find("SomeObjectType.myField")
Example: Finding arguments
MySchema.find("SomeObjectType.myField.anArgument")
Example: Finding directives
MySchema.find("@include")
Public Class Methods
Source
# File lib/graphql/schema/finder.rb, line 36 def initialize(schema) @schema = schema end
Public Instance Methods
Source
# File lib/graphql/schema/finder.rb, line 40 def find(path) path = path.split(".") type_or_directive = path.shift if type_or_directive.start_with?("@") directive = schema.directives[type_or_directive[1..-1]] if directive.nil? raise MemberNotFoundError, "Could not find directive `#{type_or_directive}` in schema." end return directive if path.empty? find_in_directive(directive, path: path) else type = schema.get_type(type_or_directive) # rubocop:disable Development/ContextIsPassedCop -- build-time if type.nil? raise MemberNotFoundError, "Could not find type `#{type_or_directive}` in schema." end return type if path.empty? find_in_type(type, path: path) end end