Skip to content

Commit 56a01ca

Browse files
refactor: Documentation and cleanup
1 parent 2c079a2 commit 56a01ca

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

Sources/GraphQL/Type/Definition.swift

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ public final class GraphQLObjectType: @unchecked Sendable {
276276
public let name: String
277277
public let description: String?
278278

279-
// While technically not sendable, fields and interfaces should not be mutated after schema
280-
// creation.
279+
/// The fields that the object defines. These may be mutated during setup, but should not be
280+
/// modified once the schema is being used for execution.
281281
public var fields: () throws -> GraphQLFieldMap {
282282
get {
283283
fieldFunc
@@ -294,6 +294,8 @@ public final class GraphQLObjectType: @unchecked Sendable {
294294
private var fieldFunc: () throws -> GraphQLFieldMap
295295
private var fieldCache: GraphQLFieldDefinitionMap?
296296

297+
/// The interfaces that the object conforms to. These may be mutated during setup, but should
298+
/// not be modified once the schema is being used for execution.
297299
public var interfaces: () throws -> [GraphQLInterfaceType] {
298300
get {
299301
interfaceFunc
@@ -306,7 +308,6 @@ public final class GraphQLObjectType: @unchecked Sendable {
306308
}
307309
}
308310
}
309-
310311
private var interfaceFunc: () throws -> [GraphQLInterfaceType]
311312
private var interfaceCache: [GraphQLInterfaceType]?
312313

@@ -511,7 +512,6 @@ public final class GraphQLField: @unchecked Sendable {
511512
public let deprecationReason: String?
512513
public let description: String?
513514

514-
private var _resolve: GraphQLFieldResolve?
515515
public var resolve: GraphQLFieldResolve? {
516516
get {
517517
fieldPropertyQueue.sync { _resolve }
@@ -521,7 +521,8 @@ public final class GraphQLField: @unchecked Sendable {
521521
}
522522
}
523523

524-
private var _subscribe: GraphQLFieldResolve?
524+
private var _resolve: GraphQLFieldResolve?
525+
525526
public var subscribe: GraphQLFieldResolve? {
526527
get {
527528
fieldPropertyQueue.sync { _subscribe }
@@ -531,6 +532,8 @@ public final class GraphQLField: @unchecked Sendable {
531532
}
532533
}
533534

535+
private var _subscribe: GraphQLFieldResolve?
536+
534537
public let astNode: FieldDefinition?
535538

536539
public init(
@@ -563,8 +566,8 @@ public final class GraphQLField: @unchecked Sendable {
563566
self.deprecationReason = deprecationReason
564567
self.description = description
565568
self.astNode = astNode
566-
self._resolve = resolve
567-
self._subscribe = subscribe
569+
_resolve = resolve
570+
_subscribe = subscribe
568571
}
569572

570573
public init(
@@ -581,7 +584,7 @@ public final class GraphQLField: @unchecked Sendable {
581584
self.description = description
582585
self.astNode = astNode
583586

584-
self._resolve = { source, args, context, info in
587+
_resolve = { source, args, context, info in
585588
let result = try resolve(source, args, context, info)
586589
return result
587590
}
@@ -730,8 +733,8 @@ public final class GraphQLInterfaceType: @unchecked Sendable {
730733
public let description: String?
731734
public let resolveType: GraphQLTypeResolve?
732735

733-
// While technically not sendable, fields and interfaces should not be mutated after schema
734-
// creation.
736+
/// The fields that the interface defines. These may be mutated during setup, but should not be
737+
/// modified once the schema is being used for execution.
735738
public var fields: () throws -> GraphQLFieldMap {
736739
get {
737740
fieldFunc
@@ -748,6 +751,8 @@ public final class GraphQLInterfaceType: @unchecked Sendable {
748751
private var fieldFunc: () throws -> GraphQLFieldMap
749752
private var fieldCache: GraphQLFieldDefinitionMap?
750753

754+
/// The interfaces that the interface conforms to. This may be mutated during setup, but should
755+
/// not be modified once the schema is being used for execution.
751756
public var interfaces: () throws -> [GraphQLInterfaceType] {
752757
get {
753758
interfaceFunc
@@ -888,7 +893,9 @@ public final class GraphQLUnionType: @unchecked Sendable {
888893
public let name: String
889894
public let description: String?
890895
public let resolveType: GraphQLTypeResolve?
891-
// While technically not sendable, types should not be mutated after schema creation.
896+
897+
/// The types that belong to the union. This may be mutated during setup, but must not be
898+
/// modified once the schema is being used for execution.
892899
public internal(set) var types: () throws -> [GraphQLObjectType]
893900
public let possibleTypeNames: [String: Bool]
894901
let extensions: [GraphQLUnionTypeExtensions]
@@ -1183,7 +1190,9 @@ public struct GraphQLEnumValueDefinition: Sendable {
11831190
public final class GraphQLInputObjectType: @unchecked Sendable {
11841191
public let name: String
11851192
public let description: String?
1186-
// While technically not sendable, this should not be mutated after schema creation.
1193+
1194+
/// The fields that the input has. This may be mutated during setup, but must not be modified
1195+
/// once the schema is being used for execution.
11871196
public var fields: () throws -> InputObjectFieldMap
11881197
public let astNode: InputObjectTypeDefinition?
11891198
public let extensionASTNodes: [InputObjectExtensionDefinition]

0 commit comments

Comments
 (0)