lib/graphql/schema/loader.rb in graphql-1.0.0 vs lib/graphql/schema/loader.rb in graphql-1.1.0
- old
+ new
@@ -8,10 +8,11 @@
extend self
# Create schema with the result of an introspection query.
# @param introspection_result [Hash] A response from {GraphQL::Introspection::INTROSPECTION_QUERY}
# @return [GraphQL::Schema] the schema described by `input`
+ # @deprecated Use {GraphQL::Schema.from_introspection} instead
def load(introspection_result)
schema = introspection_result.fetch("data").fetch("__schema")
types = {}
type_resolver = ->(type) { -> { resolve_type(types, type) } }
@@ -107,20 +108,12 @@
type: type_resolver.call(type["type"]),
description: type["description"],
default_value: type["defaultValue"] ? JSON.parse(type["defaultValue"], quirks_mode: true) : nil
)
when "SCALAR"
- case type.fetch("name")
- when "Int"
- INT_TYPE
- when "String"
- STRING_TYPE
- when "Float"
- FLOAT_TYPE
- when "Boolean"
- BOOLEAN_TYPE
- when "ID"
- ID_TYPE
+ type_name = type.fetch("name")
+ if GraphQL::Schema::BUILT_IN_TYPES[type_name]
+ GraphQL::Schema::BUILT_IN_TYPES[type_name]
else
ScalarType.define(
name: type["name"],
description: type["description"]
)