From 020dce9ee1feaaca2d384a48e07ac94f95903da9 Mon Sep 17 00:00:00 2001 From: Jay Herron Date: Sun, 11 Jan 2026 21:48:33 -0700 Subject: [PATCH 1/3] docs: Updates readme badges They now use Platform & Version data from swiftpackageindex. Codebeat was dropped, since the links were no longer valid. --- README.md | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index b2efcb6..9e7eb38 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,10 @@ Graphiti is a Swift library for building GraphQL schemas fast, safely and easily. -[![Swift][swift-badge]][swift-url] +[![Platforms][platforms-badge]][platforms-url] +[![Versions][versions-badge]][versions-url] [![License][mit-badge]][mit-url] [![GitHub Actions][gh-actions-badge]][gh-actions-url] -[![Maintainability][maintainability-badge]][maintainability-url] -[![Coverage][coverage-badge]][coverage-url] Looking for help? Find resources [from the community](http://graphql.org/community/). @@ -249,6 +248,12 @@ swiftformat . This project is released under the MIT license. See [LICENSE](LICENSE) for details. +[platforms-badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2FGraphiti%2Fbadge%3Ftype%3Dplatforms +[platforms-url]: https://swiftpackageindex.com/GraphQLSwift/Graphiti + +[versions-badge]: https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FGraphQLSwift%2FGraphiti%2Fbadge%3Ftype%3Dswift-versions +[versions-url]: https://swiftpackageindex.com/GraphQLSwift/Graphiti + [swift-badge]: https://img.shields.io/badge/Swift-5.4-orange.svg?style=flat [swift-url]: https://swift.org @@ -257,9 +262,3 @@ This project is released under the MIT license. See [LICENSE](LICENSE) for detai [gh-actions-badge]: https://github.com/GraphQLSwift/Graphiti/workflows/Tests/badge.svg [gh-actions-url]: https://github.com/GraphQLSwift/Graphiti/actions?query=workflow%3ATests - -[maintainability-badge]: https://api.codeclimate.com/v1/badges/25559824033fc2caa94e/maintainability -[maintainability-url]: https://codeclimate.com/github/GraphQLSwift/Graphiti/maintainability - -[coverage-badge]: https://api.codeclimate.com/v1/badges/25559824033fc2caa94e/test_coverage -[coverage-url]: https://codeclimate.com/github/GraphQLSwift/Graphiti/test_coverage From 452d1a637241e7825076102b4a47146fe3c9dc66 Mon Sep 17 00:00:00 2001 From: Jay Herron Date: Fri, 6 Feb 2026 23:57:09 -0700 Subject: [PATCH 2/3] chore: Formatting --- Sources/Graphiti/Federation/Queries.swift | 3 +-- Sources/Graphiti/Field/Field/Field.swift | 2 +- .../Graphiti/SchemaBuilders/PartialSchema.swift | 16 ++++++++++++---- Tests/GraphitiTests/PartialSchemaTests.swift | 6 +++--- Tests/GraphitiTests/ScalarTests.swift | 5 ----- Tests/GraphitiTests/SchemaTests.swift | 4 ++-- .../StarWarsIntrospectionTests.swift | 3 +-- Tests/GraphitiTests/ValidationRulesTests.swift | 6 ++++-- 8 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Sources/Graphiti/Federation/Queries.swift b/Sources/Graphiti/Federation/Queries.swift index c622ba4..c69576c 100644 --- a/Sources/Graphiti/Federation/Queries.swift +++ b/Sources/Graphiti/Federation/Queries.swift @@ -5,8 +5,7 @@ func serviceQuery(for sdl: String) -> GraphQLField { type: GraphQLNonNull(serviceType), description: "Return the SDL string for the subschema", resolve: { _, _, _, _ in - let result = Service(sdl: sdl) - return result + Service(sdl: sdl) } ) } diff --git a/Sources/Graphiti/Field/Field/Field.swift b/Sources/Graphiti/Field/Field/Field.swift index 9664e76..b93a5ad 100644 --- a/Sources/Graphiti/Field/Field/Field.swift +++ b/Sources/Graphiti/Field/Field/Field.swift @@ -150,5 +150,5 @@ public extension Field where Arguments == NoArguments { } } -// We must conform KeyPath to unchecked sendable to allow keypath-based resolvers. +/// We must conform KeyPath to unchecked sendable to allow keypath-based resolvers. extension KeyPath: @retroactive @unchecked Sendable {} diff --git a/Sources/Graphiti/SchemaBuilders/PartialSchema.swift b/Sources/Graphiti/SchemaBuilders/PartialSchema.swift index af5821c..50a01d7 100644 --- a/Sources/Graphiti/SchemaBuilders/PartialSchema.swift +++ b/Sources/Graphiti/SchemaBuilders/PartialSchema.swift @@ -32,16 +32,24 @@ open class PartialSchema { } /// Definitions of types - open var types: Types { typedef } + open var types: Types { + typedef + } /// Definitions of query operation fields - open var query: Fields { querydef } + open var query: Fields { + querydef + } /// Definitions of mutation operation fields - open var mutation: Fields { mutationdef } + open var mutation: Fields { + mutationdef + } /// Definitions of subscription operation fields - open var subscription: Fields { subscriptiondef } + open var subscription: Fields { + subscriptiondef + } } public extension Schema { diff --git a/Tests/GraphitiTests/PartialSchemaTests.swift b/Tests/GraphitiTests/PartialSchemaTests.swift index 4edf914..8318a35 100644 --- a/Tests/GraphitiTests/PartialSchemaTests.swift +++ b/Tests/GraphitiTests/PartialSchemaTests.swift @@ -130,7 +130,7 @@ struct PartialSchemaTests { } @Test func partialSchema() async throws { - /// Double check if static func works and the types are inferred properly + // Double check if static func works and the types are inferred properly let schema = try Schema.create(from: [BaseSchema(), SearchSchema()]) struct PartialSchemaTestAPI: API { @@ -161,7 +161,7 @@ struct PartialSchemaTests { } @Test func partialSchemaOutOfOrder() async throws { - /// Double check if ordering of partial schema doesn't matter + // Double check if ordering of partial schema doesn't matter let schema = try Schema.create(from: [SearchSchema(), BaseSchema()]) struct PartialSchemaTestAPI: API { @@ -282,7 +282,7 @@ struct PartialSchemaTests { } ) - /// Double check if ordering of partial schema doesn't matter + // Double check if ordering of partial schema doesn't matter let schema = try Schema.create(from: [searchSchema, baseSchema]) struct PartialSchemaTestAPI: API { diff --git a/Tests/GraphitiTests/ScalarTests.swift b/Tests/GraphitiTests/ScalarTests.swift index d3c5116..851e390 100644 --- a/Tests/GraphitiTests/ScalarTests.swift +++ b/Tests/GraphitiTests/ScalarTests.swift @@ -721,9 +721,4 @@ struct StringCodedCoordinate: Codable { struct DictCodedCoordinate: Codable { let latitude: Double let longitude: Double - - init(latitude: Double, longitude: Double) { - self.latitude = latitude - self.longitude = longitude - } } diff --git a/Tests/GraphitiTests/SchemaTests.swift b/Tests/GraphitiTests/SchemaTests.swift index 0bccb6e..060731a 100644 --- a/Tests/GraphitiTests/SchemaTests.swift +++ b/Tests/GraphitiTests/SchemaTests.swift @@ -4,7 +4,7 @@ import GraphQL import Testing struct SchemaTests { - // Tests that circularly dependent objects can be used in schema and resolved correctly + /// Tests that circularly dependent objects can be used in schema and resolved correctly @Test func circularDependencies() async throws { struct A: Codable { let name: String @@ -68,7 +68,7 @@ struct SchemaTests { ) } - // Tests that we can resolve type references for named types + /// Tests that we can resolve type references for named types @Test func typeReferenceForNamedType() async throws { struct LocationObject: Codable { let id: String diff --git a/Tests/GraphitiTests/StarWarsTests/StarWarsIntrospectionTests.swift b/Tests/GraphitiTests/StarWarsTests/StarWarsIntrospectionTests.swift index cdfe374..fbb5a3f 100644 --- a/Tests/GraphitiTests/StarWarsTests/StarWarsIntrospectionTests.swift +++ b/Tests/GraphitiTests/StarWarsTests/StarWarsIntrospectionTests.swift @@ -1,8 +1,7 @@ +@testable import Graphiti import GraphQL import Testing -@testable import Graphiti - struct StarWarsIntrospectionTests { private let api = StarWarsAPI() diff --git a/Tests/GraphitiTests/ValidationRulesTests.swift b/Tests/GraphitiTests/ValidationRulesTests.swift index 5fe63d6..09569e5 100644 --- a/Tests/GraphitiTests/ValidationRulesTests.swift +++ b/Tests/GraphitiTests/ValidationRulesTests.swift @@ -4,10 +4,12 @@ import GraphQL import Testing struct ValidationRulesTests { - // Test registering custom validation rules + /// Test registering custom validation rules @Test func registeringCustomValidationRule() async throws { struct TestResolver { - var helloWorld: String { "Hellow World" } + var helloWorld: String { + "Hellow World" + } } let testSchema = try Schema { From bd3da5917d801c09bde36de40c3a9b9d6c291825 Mon Sep 17 00:00:00 2001 From: Jay Herron Date: Sat, 7 Feb 2026 00:15:00 -0700 Subject: [PATCH 3/3] text: Refactor to support formatter --- .../StarWarsTests/StarWarsQueryTests.swift | 82 +++++++++---------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/Tests/GraphitiTests/StarWarsTests/StarWarsQueryTests.swift b/Tests/GraphitiTests/StarWarsTests/StarWarsQueryTests.swift index 8e52b00..789de26 100644 --- a/Tests/GraphitiTests/StarWarsTests/StarWarsQueryTests.swift +++ b/Tests/GraphitiTests/StarWarsTests/StarWarsQueryTests.swift @@ -498,47 +498,7 @@ struct StarWarsQueryTests { } @Test func nonNullableFieldsQuery() async throws { - struct A { - func nullableA(context _: NoContext, arguments _: NoArguments) -> A? { - return A() - } - - func nonNullA(context _: NoContext, arguments _: NoArguments) -> A { - return A() - } - - func `throws`(context _: NoContext, arguments _: NoArguments) throws -> String { - struct 🏃: Error, CustomStringConvertible { - let description: String - } - - throw 🏃(description: "catch me if you can.") - } - } - - struct TestResolver { - func nullableA(context _: NoContext, arguments _: NoArguments) -> A? { - return A() - } - } - - struct MyAPI: API { - var resolver: TestResolver = .init() - - let schema = try! Schema { - Type(A.self) { - Field("nullableA", at: A.nullableA) - Field("nonNullA", at: A.nonNullA) - Field("throws", at: A.throws) - } - - Query { - Field("nullableA", at: TestResolver.nullableA) - } - } - } - let api = MyAPI() - + let api = NonNullableFieldsAPI() let result = try await api.execute( request: """ query { @@ -574,6 +534,46 @@ struct StarWarsQueryTests { ) } + struct NonNullableFieldsAPI: API { + struct A { + func nullableA(context _: NoContext, arguments _: NoArguments) -> A? { + return A() + } + + func nonNullA(context _: NoContext, arguments _: NoArguments) -> A { + return A() + } + + func `throws`(context _: NoContext, arguments _: NoArguments) throws -> String { + struct 🏃: Error, CustomStringConvertible { + let description: String + } + + throw 🏃(description: "catch me if you can.") + } + } + + struct TestResolver { + func nullableA(context _: NoContext, arguments _: NoArguments) -> A? { + return A() + } + } + + var resolver: TestResolver = .init() + + let schema = try! Schema { + Type(A.self) { + Field("nullableA", at: A.nullableA) + Field("nonNullA", at: A.nonNullA) + Field("throws", at: A.throws) + } + + Query { + Field("nullableA", at: TestResolver.nullableA) + } + } + } + @Test func searchQuery() async throws { let result = try await api.execute( request: """