Skip to content
This repository was archived by the owner on Jul 25, 2024. It is now read-only.

Commit bad241a

Browse files
committed
Add unit test for #59
1 parent a06441f commit bad241a

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/graphql/execution/executor_test.exs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,26 @@ defmodule GraphQL.Execution.Executor.ExecutorTest do
133133
assert_data(result, %{g: "Hello, world!", h: "Hello, Joe!"})
134134
end
135135

136+
test "return error when no function matches" do
137+
schema = %Schema{
138+
query: %ObjectType{
139+
name: "RootQueryType",
140+
fields: %{
141+
greeting: %{
142+
type: %String{},
143+
args: %{
144+
name: %{type: %String{}}
145+
},
146+
resolve: fn(_, %{name: name}, _) -> "Hello #{name}!!" end,
147+
}
148+
}
149+
}
150+
}
151+
152+
{_, result } = execute(schema, "query Q{greeting}")
153+
assert_has_error(result, %{message: "Could not find a resolve function for this query."})
154+
end
155+
136156
test "must specify operation name when multiple operations exist" do
137157
{_, result} = execute(TestSchema.schema, "query a {greeting} query b {greeting} query c {greeting}")
138158
assert_has_error(result, %{message: "Must provide operation name if query contains multiple operations."})

0 commit comments

Comments
 (0)