Skip to content

Commit bf127f4

Browse files
committed
add test
1 parent 408245d commit bf127f4

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

Tests/GraphQLTests/LanguageTests/SchemaParserTests.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,64 @@ class SchemaParserTests: XCTestCase {
111111
XCTAssert(result == expected)
112112
}
113113

114+
func testSchemeExtension() throws {
115+
// Based on Apollo Federation example schema: https://github.com/apollographql/apollo-federation-subgraph-compatibility/blob/main/COMPATIBILITY.md#products-schema-to-be-implemented-by-library-maintainers
116+
let source =
117+
"""
118+
extend schema
119+
@link(
120+
url: "https://specs.apollo.dev/federation/v2.0",
121+
import: [
122+
"@extends",
123+
"@external",
124+
"@key",
125+
"@inaccessible",
126+
"@override",
127+
"@provides",
128+
"@requires",
129+
"@shareable",
130+
"@tag"
131+
]
132+
)
133+
"""
134+
135+
let expected = Document(
136+
definitions: [
137+
SchemaExtensionDefinition(
138+
definition: SchemaDefinition(
139+
directives: [
140+
Directive(
141+
name: nameNode("link"),
142+
arguments: [
143+
Argument(
144+
name: nameNode("url"),
145+
value: StringValue(
146+
value: "https://specs.apollo.dev/federation/v2.0",
147+
block: false
148+
)
149+
),
150+
Argument(
151+
name: nameNode("import"),
152+
value: ListValue(values: [
153+
StringValue(value: "@extends", block: false),
154+
StringValue(value: "@external", block: false),
155+
StringValue(value: "@key", block: false),
156+
StringValue(value: "@inaccessible", block: false),
157+
StringValue(value: "@override", block: false),
158+
StringValue(value: "@provides", block: false),
159+
StringValue(value: "@requires", block: false),
160+
StringValue(value: "@shareable", block: false),
161+
StringValue(value: "@tag", block: false),
162+
]))
163+
])
164+
],
165+
operationTypes: []))
166+
])
167+
168+
let result = try parse(source: source)
169+
XCTAssert(result == expected)
170+
}
171+
114172
func testSimpleNonNullType() throws {
115173
let source = "type Hello { world: String! }"
116174

0 commit comments

Comments
 (0)