Skip to content

Commit 3aa2ed8

Browse files
refactor: Removes unnecessary DispatchQueue
This is unnecessary because we only ever write the property in its entirety without appending or modifying it in any way. This change may cause us to validate the schema multiple times concurrently early in our start up process, (which should end up with the same result), but the code simplification seems worth it.
1 parent ef8b64d commit 3aa2ed8

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

Sources/GraphQL/Type/Schema.swift

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,9 @@ public final class GraphQLSchema: @unchecked Sendable {
3434
let astNode: SchemaDefinition?
3535
let extensionASTNodes: [SchemaExtensionDefinition]
3636

37-
// Used as a cache for validateSchema().
38-
private var _validationErrors: [GraphQLError]?
39-
private let validationErrorQueue = DispatchQueue(
40-
label: "graphql.schema.validationerrors",
41-
attributes: .concurrent
42-
)
43-
var validationErrors: [GraphQLError]? {
44-
get {
45-
// Reads can occur concurrently.
46-
return validationErrorQueue.sync {
47-
_validationErrors
48-
}
49-
}
50-
set {
51-
// Writes occur sequentially.
52-
return validationErrorQueue.sync(flags: .barrier) {
53-
self._validationErrors = newValue
54-
}
55-
}
56-
}
37+
/// Used as a cache for validateSchema(). Concurrent access is not protected, so assume
38+
/// it can be changed at any time.
39+
var validationErrors: [GraphQLError]?
5740

5841
public let queryType: GraphQLObjectType?
5942
public let mutationType: GraphQLObjectType?
@@ -95,7 +78,7 @@ public final class GraphQLSchema: @unchecked Sendable {
9578
extensionASTNodes: [SchemaExtensionDefinition] = [],
9679
assumeValid: Bool = false
9780
) throws {
98-
_validationErrors = assumeValid ? [] : nil
81+
validationErrors = assumeValid ? [] : nil
9982

10083
self.description = description
10184
self.extensions = extensions

0 commit comments

Comments
 (0)