From bc29f076a71551a2c41f5109ae9914a001e9c974 Mon Sep 17 00:00:00 2001 From: Jay Herron Date: Sat, 28 Feb 2026 14:34:44 -0700 Subject: [PATCH] refactor: Fixes formatting --- Benchmarks/Benchmarks/StarWarsData.swift | 2 +- Benchmarks/Benchmarks/StarWarsSchema.swift | 4 +- Sources/GraphQL/Error/SyntaxError.swift | 4 +- Sources/GraphQL/Execution/Execute.swift | 27 ++++----- Sources/GraphQL/GraphQLRequest.swift | 2 +- Sources/GraphQL/Language/Lexer.swift | 6 +- Sources/GraphQL/Language/Parser.swift | 7 +-- Sources/GraphQL/Language/Printer.swift | 60 ++++++++++++++----- Sources/GraphQL/Language/Source.swift | 9 +-- .../GraphQL/SwiftUtilities/IsNullish.swift | 2 +- Sources/GraphQL/Type/Definition.swift | 9 ++- Sources/GraphQL/Type/Introspection.swift | 5 +- Sources/GraphQL/Type/Schema.swift | 5 +- Sources/GraphQL/Type/Validation.swift | 6 +- Sources/GraphQL/Utilities/ExtendSchema.swift | 5 +- .../Rules/NoFragmentCyclesRule.swift | 6 +- Sources/GraphQL/Validation/Validate.swift | 3 +- .../ExecutionTests/OneOfTests.swift | 3 +- .../GraphQLTests/InputTests/InputTests.swift | 8 +-- .../LanguageTests/LexerTests.swift | 12 ++-- .../LanguageTests/ParserTests.swift | 6 +- Tests/GraphQLTests/MapTests/MapTests.swift | 16 ++--- .../StarWarsTests/StarWarsData.swift | 2 +- .../StarWarsIntrospectionTests.swift | 3 +- .../StarWarsTests/StarWarsQueryTests.swift | 3 +- .../StarWarsTests/StarWarsSchema.swift | 4 +- .../SubscriptionSchema.swift | 3 +- .../SubscriptionTests/SubscriptionTests.swift | 8 +-- .../ValidationTests/ExampleSchema.swift | 34 +++++------ .../ValuesOfCorrectTypeRuleTests.swift | 6 +- 30 files changed, 137 insertions(+), 133 deletions(-) diff --git a/Benchmarks/Benchmarks/StarWarsData.swift b/Benchmarks/Benchmarks/StarWarsData.swift index c7959727..29b8bef7 100644 --- a/Benchmarks/Benchmarks/StarWarsData.swift +++ b/Benchmarks/Benchmarks/StarWarsData.swift @@ -1,6 +1,6 @@ import GraphQL -/** +/* * This defines a basic set of data for our Star Wars Schema. * * This data is hard coded for the sake of the demo, but you could imagine diff --git a/Benchmarks/Benchmarks/StarWarsSchema.swift b/Benchmarks/Benchmarks/StarWarsSchema.swift index 23841438..781f4c7a 100644 --- a/Benchmarks/Benchmarks/StarWarsSchema.swift +++ b/Benchmarks/Benchmarks/StarWarsSchema.swift @@ -1,6 +1,6 @@ import GraphQL -/** +/* * This is designed to be an end-to-end test, demonstrating * the full GraphQL stack. * @@ -11,7 +11,7 @@ import GraphQL * Wars trilogy. */ -/** +/* * Using our shorthand to describe type systems, the type system for our * Star Wars example is: * diff --git a/Sources/GraphQL/Error/SyntaxError.swift b/Sources/GraphQL/Error/SyntaxError.swift index 18f2dbe9..f7816e84 100644 --- a/Sources/GraphQL/Error/SyntaxError.swift +++ b/Sources/GraphQL/Error/SyntaxError.swift @@ -7,7 +7,7 @@ import Foundation func syntaxError(source: Source, position: Int, description: String) -> GraphQLError { let location = getLocation(source: source, position: position) - let error = GraphQLError( + return GraphQLError( message: "Syntax Error \(source.name) (\(location.line):\(location.column)) " + description + "\n\n" + @@ -15,8 +15,6 @@ func syntaxError(source: Source, position: Int, description: String) -> GraphQLE source: source, positions: [position] ) - - return error } /** diff --git a/Sources/GraphQL/Execution/Execute.swift b/Sources/GraphQL/Execution/Execute.swift index 65194cc1..856b2b3e 100644 --- a/Sources/GraphQL/Execution/Execute.swift +++ b/Sources/GraphQL/Execution/Execute.swift @@ -1,7 +1,7 @@ import Dispatch import OrderedCollections -/** +/* * Terminology * * "Definitions" are the generic name for top-level statements in the document. @@ -632,8 +632,8 @@ public func resolveField( ) } -// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField` -// function. Returns the result of `resolve` or the abrupt-return Error object. +/// Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField` +/// function. Returns the result of `resolve` or the abrupt-return Error object. func resolveOrError( resolve: GraphQLFieldResolve, source: any Sendable, @@ -649,8 +649,8 @@ func resolveOrError( } } -// This is a small wrapper around completeValue which detects and logs errors -// in the execution context. +/// This is a small wrapper around completeValue which detects and logs errors +/// in the execution context. func completeValueCatchingError( exeContext: ExecutionContext, returnType: GraphQLType, @@ -693,8 +693,8 @@ func completeValueCatchingError( } } -// This is a small wrapper around completeValue which annotates errors with -// location information. +/// This is a small wrapper around completeValue which annotates errors with +/// location information. func completeValueWithLocatedError( exeContext: ExecutionContext, returnType: GraphQLType, @@ -886,11 +886,9 @@ func completeLeafValue(returnType: GraphQLLeafType, result: (any Sendable)?) thr guard let result = result else { return .null } - let serializedResult = try returnType.serialize(value: result) + return try returnType.serialize(value: result) // Do not check for serialization to null here. Some scalars may model literals as `Map.null`. - - return serializedResult } /** @@ -1048,16 +1046,13 @@ func defaultResolve( } if let subscriptable = source as? KeySubscriptable { - let value = subscriptable[info.fieldName] - return value + return subscriptable[info.fieldName] } if let subscriptable = source as? [String: any Sendable] { - let value = subscriptable[info.fieldName] - return value + return subscriptable[info.fieldName] } if let subscriptable = source as? OrderedDictionary { - let value = subscriptable[info.fieldName] - return value + return subscriptable[info.fieldName] } let mirror = Mirror(reflecting: source) diff --git a/Sources/GraphQL/GraphQLRequest.swift b/Sources/GraphQL/GraphQLRequest.swift index f1365d1b..e894f9a7 100644 --- a/Sources/GraphQL/GraphQLRequest.swift +++ b/Sources/GraphQL/GraphQLRequest.swift @@ -12,7 +12,7 @@ public struct GraphQLRequest: Equatable, Codable, Sendable { self.variables = variables } - // To handle decoding with a default of variables = [] + /// To handle decoding with a default of variables = [] public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) query = try container.decode(String.self, forKey: .query) diff --git a/Sources/GraphQL/Language/Lexer.swift b/Sources/GraphQL/Language/Lexer.swift index 415c0cf3..4fcfebb3 100644 --- a/Sources/GraphQL/Language/Lexer.swift +++ b/Sources/GraphQL/Language/Lexer.swift @@ -16,7 +16,7 @@ func createLexer(source: Source, noLocation: Bool = false) -> Lexer { value: nil ) - let lexer = Lexer( + return Lexer( source: source, noLocation: noLocation, lastToken: startOfFileToken, @@ -25,8 +25,6 @@ func createLexer(source: Source, noLocation: Bool = false) -> Lexer { lineStart: 0, advance: advanceLexer ) - - return lexer } func advanceLexer(lexer: Lexer) throws -> Token { @@ -866,7 +864,7 @@ func readBlockString( ) } -/** +/* * blockStringValue(rawValue: String) * * Transcription of the algorithm specified in the [spec](http://spec.graphql.org/draft/#BlockStringValue()) diff --git a/Sources/GraphQL/Language/Parser.swift b/Sources/GraphQL/Language/Parser.swift index 90ef4e29..57c86d1c 100644 --- a/Sources/GraphQL/Language/Parser.swift +++ b/Sources/GraphQL/Language/Parser.swift @@ -22,8 +22,7 @@ public func parse( ) throws -> Document { do { let lexer = createLexer(source: source, noLocation: noLocation) - let document = try parseDocument(lexer: lexer) - return document + return try parseDocument(lexer: lexer) } catch let error as GraphQLError { throw error } @@ -111,7 +110,7 @@ func peekDescription(lexer: Lexer) -> Bool { return peek(lexer: lexer, kind: .string) || peek(lexer: lexer, kind: .blockstring) } -/** +/* * Description is optional StringValue */ @@ -586,7 +585,7 @@ func parseObjectField(lexer: Lexer, isConst: Bool) throws -> ObjectField { ) } -/** +/* * parseStringLiteral */ diff --git a/Sources/GraphQL/Language/Printer.swift b/Sources/GraphQL/Language/Printer.swift index 0ab59bef..3fd17914 100644 --- a/Sources/GraphQL/Language/Printer.swift +++ b/Sources/GraphQL/Language/Printer.swift @@ -13,11 +13,15 @@ private protocol Printable { private let MAX_LINE_LENGTH = 80 extension Name: Printable { - var printed: String { value } + var printed: String { + value + } } extension Variable: Printable { - var printed: String { "$" + name } + var printed: String { + "$" + name + } } // MARK: - Document @@ -108,7 +112,9 @@ extension Argument: Printable { // MARK: - Fragments extension FragmentSpread: Printable { - var printed: String { "..." + name + wrap(" ", join(directives, " ")) } + var printed: String { + "..." + name + wrap(" ", join(directives, " ")) + } } extension InlineFragment: Printable { @@ -132,11 +138,15 @@ extension FragmentDefinition: Printable { // MARK: - Value extension IntValue: Printable { - var printed: String { value } + var printed: String { + value + } } extension FloatValue: Printable { - var printed: String { value } + var printed: String { + value + } } extension StringValue: Printable { @@ -146,15 +156,21 @@ extension StringValue: Printable { } extension BooleanValue: Printable { - var printed: String { value ? "true" : "false" } + var printed: String { + value ? "true" : "false" + } } extension NullValue: Printable { - var printed: String { "null" } + var printed: String { + "null" + } } extension EnumValue: Printable { - var printed: String { value } + var printed: String { + value + } } extension ListValue: Printable { @@ -183,27 +199,37 @@ extension ObjectValue: Printable { } extension ObjectField: Printable { - var printed: String { name + ": " + value.printed } + var printed: String { + name + ": " + value.printed + } } // MARK: - Directive extension Directive: Printable { - var printed: String { "@" + name + wrap("(", join(arguments, ", "), ")") } + var printed: String { + "@" + name + wrap("(", join(arguments, ", "), ")") + } } // MARK: - Type extension NamedType: Printable { - var printed: String { name.printed } + var printed: String { + name.printed + } } extension ListType: Printable { - var printed: String { "[" + type.printed + "]" } + var printed: String { + "[" + type.printed + "]" + } } extension NonNullType: Printable { - var printed: String { type.printed + "!" } + var printed: String { + type.printed + "!" + } } // MARK: - Type System Definitions @@ -216,7 +242,9 @@ extension SchemaDefinition: Printable { } extension OperationTypeDefinition: Printable { - var printed: String { operation.rawValue + ": " + type } + var printed: String { + operation.rawValue + ": " + type + } } extension ScalarTypeDefinition: Printable { @@ -423,7 +451,9 @@ private func + (lhs: Printable, rhs: String) -> String { } extension String: Printable { - fileprivate var printed: String { self } + fileprivate var printed: String { + self + } } private extension Node { diff --git a/Sources/GraphQL/Language/Source.swift b/Sources/GraphQL/Language/Source.swift index b934fb5d..d5416bb6 100644 --- a/Sources/GraphQL/Language/Source.swift +++ b/Sources/GraphQL/Language/Source.swift @@ -7,7 +7,7 @@ * Note that since Source parsing is heavily UTF8 dependent, the body * is converted into contiguous UTF8 bytes if necessary for optimal performance. */ -public struct Source: Hashable, Sendable { +public struct Source: Hashable, Equatable, Sendable { public let body: String public let name: String @@ -19,10 +19,3 @@ public struct Source: Hashable, Sendable { self.name = name } } - -extension Source: Equatable { - public static func == (lhs: Source, rhs: Source) -> Bool { - return lhs.body == rhs.body && - lhs.name == rhs.name - } -} diff --git a/Sources/GraphQL/SwiftUtilities/IsNullish.swift b/Sources/GraphQL/SwiftUtilities/IsNullish.swift index 3300ecad..0bc24463 100644 --- a/Sources/GraphQL/SwiftUtilities/IsNullish.swift +++ b/Sources/GraphQL/SwiftUtilities/IsNullish.swift @@ -18,7 +18,7 @@ extension Optional: OptionalProtocol { } } -/** +/* * Returns true if a value is null, or nil. */ // func isNullish(_ value: Any?) -> Bool { diff --git a/Sources/GraphQL/Type/Definition.swift b/Sources/GraphQL/Type/Definition.swift index da9203d5..cb6f3b9d 100644 --- a/Sources/GraphQL/Type/Definition.swift +++ b/Sources/GraphQL/Type/Definition.swift @@ -190,17 +190,17 @@ public final class GraphQLScalarType: Sendable { self.parseLiteral = parseLiteral ?? defaultParseLiteral } - // Serializes an internal value to include in a response. + /// Serializes an internal value to include in a response. public func serialize(value: Any) throws -> Map { return try serialize(value) } - // Parses an externally provided value to use as an input. + /// Parses an externally provided value to use as an input. public func parseValue(value: Map) throws -> Map { return try parseValue(value) } - // Parses an externally provided literal value to use as an input. + /// Parses an externally provided literal value to use as an input. public func parseLiteral(valueAST: Value) throws -> Map { return try parseLiteral(valueAST) } @@ -586,8 +586,7 @@ public final class GraphQLField: @unchecked Sendable { self.astNode = astNode _resolve = { source, args, context, info in - let result = try resolve(source, args, context, info) - return result + try resolve(source, args, context, info) } _subscribe = nil } diff --git a/Sources/GraphQL/Type/Introspection.swift b/Sources/GraphQL/Type/Introspection.swift index 185aba08..1941e9a3 100644 --- a/Sources/GraphQL/Type/Introspection.swift +++ b/Sources/GraphQL/Type/Introspection.swift @@ -327,8 +327,7 @@ let __Type: GraphQLObjectType = { } let fieldMap = try type.getFields() - let fields = Array(fieldMap.values).sorted(by: { $0.name < $1.name }) - return fields + return Array(fieldMap.values).sorted(by: { $0.name < $1.name }) } ), "ofType": GraphQLField(type: __Type), @@ -483,7 +482,7 @@ let __TypeKind = try! GraphQLEnumType( ] ) -/** +/* * Note that these are GraphQLFieldDefinition and not GraphQLField, * so the format for args is different. */ diff --git a/Sources/GraphQL/Type/Schema.swift b/Sources/GraphQL/Type/Schema.swift index 95a9989d..7026851b 100644 --- a/Sources/GraphQL/Type/Schema.swift +++ b/Sources/GraphQL/Type/Schema.swift @@ -130,7 +130,7 @@ public final class GraphQLSchema: @unchecked Sendable { // Storing the resulting map for reference by the schema. var typeMap = TypeMap() - // Keep track of all implementations by interface name. + /// Keep track of all implementations by interface name. func collectImplementations( types: [GraphQLNamedType] ) throws -> [String: InterfaceImplementations] { @@ -292,8 +292,7 @@ public final class GraphQLSchema: @unchecked Sendable { subTypeMap[abstractType.name] = map } - let isSubType = map?[maybeSubType.name] != nil - return isSubType + return map?[maybeSubType.name] != nil } public func getDirective(name: String) -> GraphQLDirective? { diff --git a/Sources/GraphQL/Type/Validation.swift b/Sources/GraphQL/Type/Validation.swift index af863826..605cc8a4 100644 --- a/Sources/GraphQL/Type/Validation.swift +++ b/Sources/GraphQL/Type/Validation.swift @@ -699,9 +699,9 @@ func createInputObjectCircularRefsValidator( return detectCycleRecursive - // This does a straight-forward DFS to find cycles. - // It does not terminate when a cycle is found but continues to explore - // the graph to find all possible cycles. + /// This does a straight-forward DFS to find cycles. + /// It does not terminate when a cycle is found but continues to explore + /// the graph to find all possible cycles. func detectCycleRecursive(inputObj: GraphQLInputObjectType) throws { if visitedTypes.contains(inputObj) { return diff --git a/Sources/GraphQL/Utilities/ExtendSchema.swift b/Sources/GraphQL/Utilities/ExtendSchema.swift index acca734c..ed9dff22 100644 --- a/Sources/GraphQL/Utilities/ExtendSchema.swift +++ b/Sources/GraphQL/Utilities/ExtendSchema.swift @@ -243,7 +243,7 @@ func extendSchemaImpl( name: type.name, description: type.description, fields: { - let fields = try type.getFields().mapValues { field in + try type.getFields().mapValues { field in InputObjectField( type: replaceType(field.type), defaultValue: field.defaultValue, @@ -252,7 +252,6 @@ func extendSchemaImpl( astNode: field.astNode ) }.merging(buildInputFieldMap(nodes: extensions)) { $1 } - return fields }, astNode: type.astNode, extensionASTNodes: extensionASTNodes @@ -960,7 +959,7 @@ let stdTypeMap = { return typeMap }() -/** +/* * Given a field or enum value node, returns the string value for the * deprecation reason. */ diff --git a/Sources/GraphQL/Validation/Rules/NoFragmentCyclesRule.swift b/Sources/GraphQL/Validation/Rules/NoFragmentCyclesRule.swift index f2a47b3d..8d883051 100644 --- a/Sources/GraphQL/Validation/Rules/NoFragmentCyclesRule.swift +++ b/Sources/GraphQL/Validation/Rules/NoFragmentCyclesRule.swift @@ -18,9 +18,9 @@ func NoFragmentCyclesRule(context: ValidationContext) -> Visitor { // Position in the spread path var spreadPathIndexByName = [String: Int]() - // This does a straight-forward DFS to find cycles. - // It does not terminate when a cycle was found but continues to explore - // the graph to find all possible cycles. + /// This does a straight-forward DFS to find cycles. + /// It does not terminate when a cycle was found but continues to explore + /// the graph to find all possible cycles. func detectCycleRecursive(fragment: FragmentDefinition) { if visitedFrags.contains(fragment.name.value) { return diff --git a/Sources/GraphQL/Validation/Validate.swift b/Sources/GraphQL/Validation/Validate.swift index 27e72602..3d6d74fc 100644 --- a/Sources/GraphQL/Validation/Validate.swift +++ b/Sources/GraphQL/Validation/Validate.swift @@ -18,8 +18,7 @@ public func validate( ) -> [GraphQLError] { let typeInfo = TypeInfo(schema: schema) let rules = rules.isEmpty ? specifiedRules : rules - let errors = visit(usingRules: rules, schema: schema, typeInfo: typeInfo, documentAST: ast) - return errors + return visit(usingRules: rules, schema: schema, typeInfo: typeInfo, documentAST: ast) } /** diff --git a/Tests/GraphQLTests/ExecutionTests/OneOfTests.swift b/Tests/GraphQLTests/ExecutionTests/OneOfTests.swift index 5f52ea1f..d15e883f 100644 --- a/Tests/GraphQLTests/ExecutionTests/OneOfTests.swift +++ b/Tests/GraphQLTests/ExecutionTests/OneOfTests.swift @@ -161,7 +161,7 @@ func getSchema() throws -> GraphQLSchema { ], isOneOf: true ) - let schema = try GraphQLSchema( + return try GraphQLSchema( query: GraphQLObjectType( name: "Query", fields: [ @@ -181,7 +181,6 @@ func getSchema() throws -> GraphQLSchema { testInputObject, ] ) - return schema } struct TestObject: Codable { diff --git a/Tests/GraphQLTests/InputTests/InputTests.swift b/Tests/GraphQLTests/InputTests/InputTests.swift index 09dc7ee1..a382763b 100644 --- a/Tests/GraphQLTests/InputTests/InputTests.swift +++ b/Tests/GraphQLTests/InputTests/InputTests.swift @@ -704,7 +704,7 @@ import Testing ) } - // Test that input objects parse as expected from non-null literals + /// Test that input objects parse as expected from non-null literals @Test func inputNoNull() async throws { struct Echo: Codable { let field1: String? @@ -832,7 +832,7 @@ import Testing ) } - // Test that inputs parse as expected when null literals are present + /// Test that inputs parse as expected when null literals are present @Test func inputParsingDefinedNull() async throws { struct Echo: Codable { let field1: String? @@ -960,7 +960,7 @@ import Testing ) } - // Test that input objects parse as expected when there are missing fields with no default + /// Test that input objects parse as expected when there are missing fields with no default @Test func inputParsingUndefined() async throws { struct Echo: Codable { let field1: String? @@ -1087,7 +1087,7 @@ import Testing ) } - // Test that input objects parse as expected when there are missing fields with defaults + /// Test that input objects parse as expected when there are missing fields with defaults @Test func inputParsingUndefinedWithDefault() async throws { struct Echo: Codable { let field1: String? diff --git a/Tests/GraphQLTests/LanguageTests/LexerTests.swift b/Tests/GraphQLTests/LanguageTests/LexerTests.swift index 0db58090..134928bf 100644 --- a/Tests/GraphQLTests/LanguageTests/LexerTests.swift +++ b/Tests/GraphQLTests/LanguageTests/LexerTests.swift @@ -767,7 +767,7 @@ func lexOne(_ string: String) throws -> Token { // Tests for Blockstring support // - @Test func blockStringIndentAndBlankLine() throws { + @Test func blockStringIndentAndBlankLine() { let rawString = """ @@ -792,7 +792,7 @@ func lexOne(_ string: String) throws -> Token { """) } - @Test func blockStringDoubleIndentAndBlankLine() throws { + @Test func blockStringDoubleIndentAndBlankLine() { let rawString = """ @@ -823,7 +823,7 @@ func lexOne(_ string: String) throws -> Token { ) } - @Test func blockStringIndentAndBlankLineFirstLineNotIndent() throws { + @Test func blockStringIndentAndBlankLineFirstLineNotIndent() { let rawString = """ @@ -847,7 +847,7 @@ func lexOne(_ string: String) throws -> Token { """) } - @Test func blockStringIndentBlankLineFirstLineNotIndentWeird() throws { + @Test func blockStringIndentBlankLineFirstLineNotIndentWeird() { let rawString = """ @@ -869,7 +869,7 @@ func lexOne(_ string: String) throws -> Token { """) } - @Test func blockStringIndentMultilineWithSingleSpaceIndent() throws { + @Test func blockStringIndentMultilineWithSingleSpaceIndent() { let rawString = """ Multi-line string With Inner \"foo\" @@ -884,7 +884,7 @@ func lexOne(_ string: String) throws -> Token { """) } - @Test func blockStringIndentMultilineWithSingleSpaceIndentExtraLines() throws { + @Test func blockStringIndentMultilineWithSingleSpaceIndentExtraLines() { let rawString = """ Multi-line string diff --git a/Tests/GraphQLTests/LanguageTests/ParserTests.swift b/Tests/GraphQLTests/LanguageTests/ParserTests.swift index 4c3346e6..1befe83d 100644 --- a/Tests/GraphQLTests/LanguageTests/ParserTests.swift +++ b/Tests/GraphQLTests/LanguageTests/ParserTests.swift @@ -461,9 +461,9 @@ import Testing } } -// This function exists because `error = #require(throwing: GraphQLError) { ... }` doesn't work -// until Swift 6.1. Once we drop 6.0 support, we can change all calls of this to -// `error = #require(throwing: GraphQLError) { ... }` +/// This function exists because `error = #require(throwing: GraphQLError) { ... }` doesn't work +/// until Swift 6.1. Once we drop 6.0 support, we can change all calls of this to +/// `error = #require(throwing: GraphQLError) { ... }` private func expectGraphQLError(_ test: () throws -> T) throws -> GraphQLError { do { _ = try test() diff --git a/Tests/GraphQLTests/MapTests/MapTests.swift b/Tests/GraphQLTests/MapTests/MapTests.swift index e956cb77..6333cfa2 100644 --- a/Tests/GraphQLTests/MapTests/MapTests.swift +++ b/Tests/GraphQLTests/MapTests/MapTests.swift @@ -52,7 +52,7 @@ import Testing #expect(dictionary["fifth"]?.isUndefined == true) } - // Ensure that default decoding preserves undefined becoming nil + /// Ensure that default decoding preserves undefined becoming nil @Test func nilAndUndefinedDecodeToNilByDefault() throws { struct DecodableTest: Codable { let first: Int? @@ -77,11 +77,11 @@ import Testing #expect(decodable.fourth == nil) } - // Ensure that, if custom decoding is defined, provided nulls and unset values can be - // differentiated. - // This should match JSON in that values set to `null` should be 'contained' by the container, - // but - // values expected by the result that are undefined or not present should not be. + /// Ensure that, if custom decoding is defined, provided nulls and unset values can be + /// differentiated. + /// This should match JSON in that values set to `null` should be 'contained' by the container, + /// but + /// values expected by the result that are undefined or not present should not be. @Test func nilAndUndefinedDecoding() throws { struct DecodableTest: Codable { let first: Int? @@ -131,7 +131,7 @@ import Testing _ = try MapDecoder().decode(DecodableTest.self, from: map) } - // Ensure that map encoding includes defined nulls, but skips undefined values + /// Ensure that map encoding includes defined nulls, but skips undefined values @Test func mapEncodingNilAndUndefined() throws { let map = Map.dictionary( [ @@ -150,7 +150,7 @@ import Testing ) } - // Ensure that GraphQLJSONEncoder preserves map dictionary order in output + /// Ensure that GraphQLJSONEncoder preserves map dictionary order in output @Test func mapEncodingOrderPreserved() throws { // Test top level #expect( diff --git a/Tests/GraphQLTests/StarWarsTests/StarWarsData.swift b/Tests/GraphQLTests/StarWarsTests/StarWarsData.swift index c7959727..29b8bef7 100644 --- a/Tests/GraphQLTests/StarWarsTests/StarWarsData.swift +++ b/Tests/GraphQLTests/StarWarsTests/StarWarsData.swift @@ -1,6 +1,6 @@ import GraphQL -/** +/* * This defines a basic set of data for our Star Wars Schema. * * This data is hard coded for the sake of the demo, but you could imagine diff --git a/Tests/GraphQLTests/StarWarsTests/StarWarsIntrospectionTests.swift b/Tests/GraphQLTests/StarWarsTests/StarWarsIntrospectionTests.swift index e803f812..c30437b6 100644 --- a/Tests/GraphQLTests/StarWarsTests/StarWarsIntrospectionTests.swift +++ b/Tests/GraphQLTests/StarWarsTests/StarWarsIntrospectionTests.swift @@ -1,6 +1,5 @@ -import Testing - @testable import GraphQL +import Testing @Suite struct StarWarsIntrospectionTests { @Test func introspectionTypeQuery() async throws { diff --git a/Tests/GraphQLTests/StarWarsTests/StarWarsQueryTests.swift b/Tests/GraphQLTests/StarWarsTests/StarWarsQueryTests.swift index 55ba17cb..0be7c282 100644 --- a/Tests/GraphQLTests/StarWarsTests/StarWarsQueryTests.swift +++ b/Tests/GraphQLTests/StarWarsTests/StarWarsQueryTests.swift @@ -1,6 +1,5 @@ -import Testing - @testable import GraphQL +import Testing @Suite struct StarWarsQueryTests { @Test func heroNameQuery() async throws { diff --git a/Tests/GraphQLTests/StarWarsTests/StarWarsSchema.swift b/Tests/GraphQLTests/StarWarsTests/StarWarsSchema.swift index 23841438..781f4c7a 100644 --- a/Tests/GraphQLTests/StarWarsTests/StarWarsSchema.swift +++ b/Tests/GraphQLTests/StarWarsTests/StarWarsSchema.swift @@ -1,6 +1,6 @@ import GraphQL -/** +/* * This is designed to be an end-to-end test, demonstrating * the full GraphQL stack. * @@ -11,7 +11,7 @@ import GraphQL * Wars trilogy. */ -/** +/* * Using our shorthand to describe type systems, the type system for our * Star Wars example is: * diff --git a/Tests/GraphQLTests/SubscriptionTests/SubscriptionSchema.swift b/Tests/GraphQLTests/SubscriptionTests/SubscriptionSchema.swift index beaf8600..77620ed0 100644 --- a/Tests/GraphQLTests/SubscriptionTests/SubscriptionSchema.swift +++ b/Tests/GraphQLTests/SubscriptionTests/SubscriptionSchema.swift @@ -129,10 +129,9 @@ actor EmailDb { }, subscribe: { _, args, _, _ throws -> Any? in let priority = args["priority"].int ?? 0 - let filtered = await self.publisher.subscribe().filter { email throws in + return await self.publisher.subscribe().filter { email throws in return email.priority >= priority } - return filtered } ) } diff --git a/Tests/GraphQLTests/SubscriptionTests/SubscriptionTests.swift b/Tests/GraphQLTests/SubscriptionTests/SubscriptionTests.swift index 39aa98e1..4b7aca90 100644 --- a/Tests/GraphQLTests/SubscriptionTests/SubscriptionTests.swift +++ b/Tests/GraphQLTests/SubscriptionTests/SubscriptionTests.swift @@ -356,7 +356,7 @@ import Testing )) } - /// 'resolves to an error for source event stream resolver errors' + // 'resolves to an error for source event stream resolver errors' // Tests above cover this /// 'resolves to an error if variables were wrong type' @@ -711,7 +711,7 @@ import Testing #expect(results == expected) } - /// 'should not trigger when subscription is thrown' + // 'should not trigger when subscription is thrown' // Not necessary - Swift async stream handles throwing errors /// 'event order is correct for multiple publishes' @@ -861,9 +861,9 @@ import Testing #expect(results == expected) } - /// 'should pass through error thrown in source event stream' + // 'should pass through error thrown in source event stream' // Handled by AsyncThrowingStream - /// Test incorrect emitted type errors + // Test incorrect emitted type errors // Handled by strongly typed PubSub } diff --git a/Tests/GraphQLTests/ValidationTests/ExampleSchema.swift b/Tests/GraphQLTests/ValidationTests/ExampleSchema.swift index f874014b..16c20b1e 100644 --- a/Tests/GraphQLTests/ValidationTests/ExampleSchema.swift +++ b/Tests/GraphQLTests/ValidationTests/ExampleSchema.swift @@ -83,11 +83,11 @@ let ValidationExampleCanine = try! GraphQLInterfaceType( } ) -// enum DogCommand { -// SIT -// HEEL -// DOWN -// } +/// enum DogCommand { +/// SIT +/// HEEL +/// DOWN +/// } let ValidationExampleDogCommand = try! GraphQLEnumType( name: "DogCommand", values: [ @@ -202,14 +202,14 @@ let ValidationExampleDog = try! GraphQLObjectType( ] ) -// enum FurColor { -// BROWN -// BLACK -// TAN -// SPOTTED -// NO_FUR -// UNKNOWN -// } +/// enum FurColor { +/// BROWN +/// BLACK +/// TAN +/// SPOTTED +/// NO_FUR +/// UNKNOWN +/// } let ValidationExampleFurColor = try! GraphQLEnumType( name: "FurColor", values: [ @@ -260,7 +260,7 @@ let ValidationExampleCat = try! GraphQLObjectType( interfaces: [ValidationExampleBeing, ValidationExamplePet] ) -// union CatOrDog = Cat | Dog +/// union CatOrDog = Cat | Dog let ValidationExampleCatOrDog = try! GraphQLUnionType( name: "CatOrDog", resolveType: { _, _ in @@ -354,7 +354,7 @@ let ValidationExampleHuman = try! GraphQLObjectType( interfaces: [ValidationExampleBeing, ValidationExampleIntelligent] ) -// enum CatCommand { JUMP } +/// enum CatCommand { JUMP } let ValidationExampleCatCommand = try! GraphQLEnumType( name: "CatCommand", values: [ @@ -364,7 +364,7 @@ let ValidationExampleCatCommand = try! GraphQLEnumType( ] ) -// union DogOrHuman = Dog | Human +/// union DogOrHuman = Dog | Human let ValidationExampleDogOrHuman = try! GraphQLUnionType( name: "DogOrHuman", resolveType: { _, _ in @@ -373,7 +373,7 @@ let ValidationExampleDogOrHuman = try! GraphQLUnionType( types: [ValidationExampleDog, ValidationExampleHuman] ) -// union HumanOrAlien = Human | Alien +/// union HumanOrAlien = Human | Alien let ValidationExampleHumanOrAlien = try! GraphQLUnionType( name: "HumanOrAlien", resolveType: { _, _ in diff --git a/Tests/GraphQLTests/ValidationTests/ValuesOfCorrectTypeRuleTests.swift b/Tests/GraphQLTests/ValidationTests/ValuesOfCorrectTypeRuleTests.swift index f48304f1..059496e2 100644 --- a/Tests/GraphQLTests/ValidationTests/ValuesOfCorrectTypeRuleTests.swift +++ b/Tests/GraphQLTests/ValidationTests/ValuesOfCorrectTypeRuleTests.swift @@ -1154,7 +1154,7 @@ class ValuesOfCorrectTypeRuleTests: ValidationTestCase { } ) - let schema = try! GraphQLSchema( + let schema = try GraphQLSchema( query: GraphQLObjectType( name: "Query", fields: [ @@ -1192,7 +1192,7 @@ class ValuesOfCorrectTypeRuleTests: ValidationTestCase { } ) - let schema = try! GraphQLSchema( + let schema = try GraphQLSchema( query: GraphQLObjectType( name: "Query", fields: [ @@ -1224,7 +1224,7 @@ class ValuesOfCorrectTypeRuleTests: ValidationTestCase { } ) - let schema = try! GraphQLSchema( + let schema = try GraphQLSchema( query: GraphQLObjectType( name: "Query", fields: [