File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ def self.load_schema(schema)
5454 when String
5555 if schema . end_with? ( ".json" ) && File . exist? ( schema )
5656 load_schema ( File . read ( schema ) )
57+ elsif ( schema . end_with? ( ".graphql" , ".graphqls" ) ) && File . exist? ( schema )
58+ GraphQL ::Schema . from_definition ( schema )
5759 elsif schema =~ /\A \s *{/
5860 load_schema ( JSON . parse ( schema , freeze : true ) )
5961 end
Original file line number Diff line number Diff line change @@ -42,6 +42,12 @@ def test_load_schema_from_json_string
4242 assert_equal "AwesomeQuery" , schema . query . graphql_name
4343 end
4444
45+ def test_load_schema_from_definition_string
46+ definition = Schema . to_definition
47+ schema = GraphQL ::Client . load_schema ( definition )
48+ assert_equal "AwesomeQuery" , schema . query . graphql_name
49+ end
50+
4551 def test_load_schema_ignores_missing_path
4652 refute GraphQL ::Client . load_schema ( "#{ __dir__ } /missing-schema.json" )
4753 end
You can’t perform that action at this time.
0 commit comments