Skip to content

Commit a141143

Browse files
committed
raise ParseError for nil in Parser.parse
1 parent 61a0669 commit a141143

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

lib/graphql/language/parser.rb

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/graphql/language/parser.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,7 @@ end
434434
---- inner ----
435435

436436
def initialize(query_string, filename:, tracer: Tracing::NullTracer)
437+
raise GraphQL::ParseError.new("No query string was present", nil, nil, query_string) if query_string.nil?
437438
@query_string = query_string
438439
@filename = filename
439440
@tracer = tracer

spec/graphql/language/parser_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,14 @@
129129
assert_equal schema_string, document.to_query_string
130130
end
131131

132+
describe "parse errors" do
133+
it "raises parse errors for nil" do
134+
assert_raises(GraphQL::ParseError) {
135+
GraphQL.parse(nil)
136+
}
137+
end
138+
end
139+
132140
describe ".parse_file" do
133141
it "assigns filename to all nodes" do
134142
example_filename = "spec/support/parser/filename_example.graphql"

0 commit comments

Comments
 (0)