lib/graphql/schema/loader.rb in graphql-1.10.0.pre1 vs lib/graphql/schema/loader.rb in graphql-1.10.0.pre2
- old
+ new
@@ -32,28 +32,34 @@
Schema.define(**kargs, raise_definition_error: true)
end
NullResolveType = ->(type, obj, ctx) {
- raise(NotImplementedError, "This schema was loaded from string, so it can't resolve types for objects")
+ raise(GraphQL::RequiredImplementationMissingError, "This schema was loaded from string, so it can't resolve types for objects")
}
NullScalarCoerce = ->(val, _ctx) { val }
class << self
private
def resolve_type(types, type)
case kind = type.fetch("kind")
when "ENUM", "INTERFACE", "INPUT_OBJECT", "OBJECT", "SCALAR", "UNION"
- types.fetch(type.fetch("name"))
+ type_name = type.fetch("name")
+ type = types[type_name] || Schema::BUILT_IN_TYPES[type_name]
+ if type.nil?
+ raise "Type not found: #{type_name.inspect} among #{types.keys.sort}"
+ else
+ type.graphql_definition
+ end
when "LIST"
ListType.new(of_type: resolve_type(types, type.fetch("ofType")))
when "NON_NULL"
NonNullType.new(of_type: resolve_type(types, type.fetch("ofType")))
else
- fail NotImplementedError, "#{kind} not implemented"
+ fail GraphQL::RequiredImplementationMissingError, "#{kind} not implemented"
end
end
def extract_default_value(default_value_str, input_value_ast)
case input_value_ast
@@ -169,10 +175,10 @@
possible_types: type["possibleTypes"].map { |possible_type|
type_resolver.call(possible_type)
}
)
else
- fail NotImplementedError, "#{type["kind"]} not implemented"
+ fail GraphQL::RequiredImplementationMissingError, "#{type["kind"]} not implemented"
end
end
end
end
end