lib/graphql/schema/build_from_definition.rb in graphql-1.12.13 vs lib/graphql/schema/build_from_definition.rb in graphql-1.12.14

- old
+ new

@@ -45,13 +45,19 @@ type_resolver = build_resolve_type(types, directives, ->(type_name) { types[type_name] ||= Schema::LateBoundType.new(type_name)}) # Make a different type resolver because we need to coerce directive arguments # _while_ building the schema. # It will dig for a type if it encounters a custom type. This could be a problem if there are cycles. directive_type_resolver = nil - directive_type_resolver = build_resolve_type(GraphQL::Schema::BUILT_IN_TYPES, directives, ->(type_name) { + directive_type_resolver = build_resolve_type(types, directives, ->(type_name) { types[type_name] ||= begin defn = document.definitions.find { |d| d.respond_to?(:name) && d.name == type_name } - build_definition_from_node(defn, directive_type_resolver, default_resolve) + if defn + build_definition_from_node(defn, directive_type_resolver, default_resolve) + elsif (built_in_defn = GraphQL::Schema::BUILT_IN_TYPES[type_name]) + built_in_defn + else + raise "No definition for #{type_name.inspect} found in schema document or built-in types. Add a definition for it or remove it." + end end }) document.definitions.each do |definition| if definition.is_a?(GraphQL::Language::Nodes::DirectiveDefinition)