Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/GraphQL/Execution/Execute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public final class ExecutionContext: @unchecked Sendable {
}
set {
// Writes occur sequentially.
return errorsQueue.async(flags: .barrier) {
return errorsQueue.sync(flags: .barrier) {
self._errors = newValue
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/GraphQL/Type/Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public final class GraphQLSchema: @unchecked Sendable {
}
set {
// Writes occur sequentially.
return validationErrorQueue.async(flags: .barrier) {
return validationErrorQueue.sync(flags: .barrier) {
self._validationErrors = newValue
}
}
Expand Down Expand Up @@ -77,7 +77,7 @@ public final class GraphQLSchema: @unchecked Sendable {
}
set {
// Writes occur sequentially.
return subTypeMapQueue.async(flags: .barrier) {
return subTypeMapQueue.sync(flags: .barrier) {
self._subTypeMap = newValue
}
}
Expand Down
53 changes: 24 additions & 29 deletions Tests/GraphQLTests/ExecutionTests/OneOfTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
@testable import GraphQL
import XCTest
import Testing

class OneOfTests: XCTestCase {
@Suite struct OneOfTests {
// MARK: OneOf Input Objects

func testAcceptsAGoodDefaultValue() async throws {
@Test func acceptsAGoodDefaultValue() async throws {
let query = """
query ($input: TestInputObject! = {a: "abc"}) {
test(input: $input) {
Expand All @@ -17,9 +17,8 @@ class OneOfTests: XCTestCase {
schema: getSchema(),
request: query
)
XCTAssertEqual(
result,
GraphQLResult(data: [
#expect(
result == GraphQLResult(data: [
"test": [
"a": "abc",
"b": .null,
Expand All @@ -28,7 +27,7 @@ class OneOfTests: XCTestCase {
)
}

func testRejectsABadDefaultValue() async throws {
@Test func rejectsABadDefaultValue() async throws {
let query = """
query ($input: TestInputObject! = {a: "abc", b: 123}) {
test(input: $input) {
Expand All @@ -41,14 +40,14 @@ class OneOfTests: XCTestCase {
schema: getSchema(),
request: query
)
XCTAssertEqual(result.errors.count, 1)
XCTAssertEqual(
result.errors[0].message,
"OneOf Input Object \"TestInputObject\" must specify exactly one key."
#expect(result.errors.count == 1)
#expect(
result.errors[0].message ==
"OneOf Input Object \"TestInputObject\" must specify exactly one key."
)
}

func testAcceptsAGoodVariable() async throws {
@Test func acceptsAGoodVariable() async throws {
let query = """
query ($input: TestInputObject!) {
test(input: $input) {
Expand All @@ -62,9 +61,8 @@ class OneOfTests: XCTestCase {
request: query,
variableValues: ["input": ["a": "abc"]]
)
XCTAssertEqual(
result,
GraphQLResult(data: [
#expect(
result == GraphQLResult(data: [
"test": [
"a": "abc",
"b": .null,
Expand All @@ -73,7 +71,7 @@ class OneOfTests: XCTestCase {
)
}

func testAcceptsAGoodVariableWithAnUndefinedKey() async throws {
@Test func acceptsAGoodVariableWithAnUndefinedKey() async throws {
let query = """
query ($input: TestInputObject!) {
test(input: $input) {
Expand All @@ -87,9 +85,8 @@ class OneOfTests: XCTestCase {
request: query,
variableValues: ["input": ["a": "abc", "b": .undefined]]
)
XCTAssertEqual(
result,
GraphQLResult(data: [
#expect(
result == GraphQLResult(data: [
"test": [
"a": "abc",
"b": .null,
Expand All @@ -98,7 +95,7 @@ class OneOfTests: XCTestCase {
)
}

func testRejectsAVariableWithMultipleNonNullKeys() async throws {
@Test func rejectsAVariableWithMultipleNonNullKeys() async throws {
let query = """
query ($input: TestInputObject!) {
test(input: $input) {
Expand All @@ -112,17 +109,16 @@ class OneOfTests: XCTestCase {
request: query,
variableValues: ["input": ["a": "abc", "b": 123]]
)
XCTAssertEqual(result.errors.count, 1)
XCTAssertEqual(
result.errors[0].message,
"""
#expect(result.errors.count == 1)
#expect(
result.errors[0].message == """
Variable "$input" got invalid value "{"a":"abc","b":123}".
Exactly one key must be specified for OneOf type "TestInputObject".
"""
)
}

func testRejectsAVariableWithMultipleNullableKeys() async throws {
@Test func rejectsAVariableWithMultipleNullableKeys() async throws {
let query = """
query ($input: TestInputObject!) {
test(input: $input) {
Expand All @@ -136,10 +132,9 @@ class OneOfTests: XCTestCase {
request: query,
variableValues: ["input": ["a": "abc", "b": .null]]
)
XCTAssertEqual(result.errors.count, 1)
XCTAssertEqual(
result.errors[0].message,
"""
#expect(result.errors.count == 1)
#expect(
result.errors[0].message == """
Variable "$input" got invalid value "{"a":"abc","b":null}".
Exactly one key must be specified for OneOf type "TestInputObject".
"""
Expand Down
10 changes: 5 additions & 5 deletions Tests/GraphQLTests/FederationTests/FederationTests.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
@testable import GraphQL
import XCTest
import Testing

final class FederationTests: XCTestCase {
func testFederationSampleSchema() throws {
@Suite struct FederationTests {
@Test func federationSampleSchema() throws {
// Confirm that the Apollo test schema can be parsed as expected https://github.com/apollographql/apollo-federation-subgraph-compatibility/blob/main/COMPATIBILITY.md
let source =
"""
Expand Down Expand Up @@ -328,7 +328,7 @@ final class FederationTests: XCTestCase {
let document = try parse(source: source)
let printed = print(ast: document)

XCTAssertEqual(document, expected)
XCTAssertEqual(source, printed)
#expect(document == expected)
#expect(source == printed)
}
}
16 changes: 8 additions & 8 deletions Tests/GraphQLTests/HelloWorldTests/HelloWorldTests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@testable import GraphQL
import XCTest
import Testing

class HelloWorldTests: XCTestCase {
@Suite struct HelloWorldTests {
let schema = try! GraphQLSchema(
query: GraphQLObjectType(
name: "RootQueryType",
Expand All @@ -16,7 +16,7 @@ class HelloWorldTests: XCTestCase {
)
)

func testHello() async throws {
@Test func hello() async throws {
let query = "{ hello }"
let expected = GraphQLResult(data: ["hello": "world"])

Expand All @@ -25,10 +25,10 @@ class HelloWorldTests: XCTestCase {
request: query
)

XCTAssertEqual(result, expected)
#expect(result == expected)
}

func testBoyhowdy() async throws {
@Test func boyhowdy() async throws {
let query = "{ boyhowdy }"

let expected = GraphQLResult(
Expand All @@ -45,10 +45,10 @@ class HelloWorldTests: XCTestCase {
request: query
)

XCTAssertEqual(result, expected)
#expect(result == expected)
}

func testHelloAsync() async throws {
@Test func helloAsync() async throws {
let query = "{ hello }"
let expected = GraphQLResult(data: ["hello": "world"])

Expand All @@ -57,6 +57,6 @@ class HelloWorldTests: XCTestCase {
request: query
)

XCTAssertEqual(result, expected)
#expect(result == expected)
}
}
Loading
Loading