Skip to content

Commit c4baf42

Browse files
committed
add test for schema with no query or federated resolvers
1 parent 25a3a7c commit c4baf42

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

Tests/GraphitiTests/SchemaTests.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ class SchemaTests: XCTestCase {
140140
])
141141
)
142142
}
143+
144+
func testSchemaWithNoQuery() {
145+
struct User: Codable {
146+
let id: String
147+
}
148+
149+
struct TestResolver {}
150+
151+
do {
152+
let _ = try Schema<TestResolver, NoContext> {
153+
Type(User.self) {
154+
Field("id", at: \.id)
155+
}
156+
}
157+
} catch {
158+
XCTAssertEqual(
159+
error as? SchemaError,
160+
SchemaError(
161+
description: "Schema must contain at least 1 query or federated resolver"
162+
)
163+
)
164+
}
165+
}
143166
}
144167

145168
private class TestAPI<Resolver, ContextType>: API {

0 commit comments

Comments
 (0)