File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,8 @@ def self.load_schema(schema)
5858 GraphQL ::Schema . from_definition ( schema )
5959 elsif schema =~ /\A \s *{/
6060 load_schema ( JSON . parse ( schema , freeze : true ) )
61+ elsif schema . start_with? ( "schema" )
62+ GraphQL ::Schema . from_definition ( schema )
6163 end
6264 else
6365 if schema . respond_to? ( :execute )
Original file line number Diff line number Diff line change @@ -48,6 +48,16 @@ def test_load_schema_from_definition_string
4848 assert_equal "AwesomeQuery" , schema . query . graphql_name
4949 end
5050
51+ def test_load_schema_from_definition_file
52+ definition = Schema . to_definition
53+ Tempfile . create ( [ "schema" , ".graphql" ] ) do |file |
54+ file . write ( definition )
55+ file . close
56+ schema = GraphQL ::Client . load_schema ( file . path )
57+ assert_equal "AwesomeQuery" , schema . query . graphql_name
58+ end
59+ end
60+
5161 def test_load_schema_ignores_missing_path
5262 refute GraphQL ::Client . load_schema ( "#{ __dir__ } /missing-schema.json" )
5363 end
You can’t perform that action at this time.
0 commit comments