Skip to content
Merged
Changes from all 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
24 changes: 21 additions & 3 deletions Sources/GraphQL/Type/Definition.swift
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,18 @@ public final class GraphQLObjectType: @unchecked Sendable {
private var interfaceFunc: () throws -> [GraphQLInterfaceType]
private var interfaceCache: [GraphQLInterfaceType]?

public let isTypeOf: GraphQLIsTypeOf?
/// The type detection for the object. This may be mutated during setup, but should
/// not be modified once the schema is being used for execution.
public var isTypeOf: GraphQLIsTypeOf? {
get {
isTypeOfQueue.sync { _isTypeOf }
}
set {
isTypeOfQueue.sync(flags: .barrier) { _isTypeOf = newValue }
}
}
private var _isTypeOf: GraphQLIsTypeOf?

public let astNode: ObjectTypeDefinition?
public let extensionASTNodes: [TypeExtensionDefinition]
public let kind: TypeKind = .object
Expand All @@ -326,7 +337,7 @@ public final class GraphQLObjectType: @unchecked Sendable {
self.description = description
fieldFunc = { fields }
interfaceFunc = { interfaces }
self.isTypeOf = isTypeOf
_isTypeOf = isTypeOf
self.astNode = astNode
self.extensionASTNodes = extensionASTNodes
}
Expand All @@ -345,7 +356,7 @@ public final class GraphQLObjectType: @unchecked Sendable {
self.description = description
fieldFunc = fields
interfaceFunc = interfaces
self.isTypeOf = isTypeOf
_isTypeOf = isTypeOf
self.astNode = astNode
self.extensionASTNodes = extensionASTNodes
}
Expand Down Expand Up @@ -1447,3 +1458,10 @@ private let scalarPropertyQueue = DispatchQueue(
label: "graphql.scalar.properties",
attributes: .concurrent
)

/// Shared queue for isTypeOf property access
/// Uses reader/writer pattern for read-heavy workload
private let isTypeOfQueue = DispatchQueue(
label: "graphql.isTypeOf.properties",
attributes: .concurrent
)
Loading