Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(apollo-ios-codegen): Stable sort schema types for SchemaMetadata #514

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IRInputObjectTests: XCTestCase {

func buildSubject() async throws {
let ir: IRBuilder = try await .mock(schema: schemaSDL, document: document)
subject = ir.schema.referencedTypes.inputObjects.first!
subject = ir.schema.referencedTypes.inputObjects[1]
BobaFetters marked this conversation as resolved.
Show resolved Hide resolved
}

// MARK: - Tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

}

public class GraphQLNamedType:
JavaScriptReferencedObject, @unchecked Sendable, Hashable, CustomDebugStringConvertible, GraphQLNamedItem {
public class GraphQLNamedType:
JavaScriptReferencedObject, @unchecked Sendable, Comparable, Hashable, CustomDebugStringConvertible, GraphQLNamedItem {
public let name: GraphQLName

public let documentation: String?
Expand Down Expand Up @@ -59,12 +59,16 @@
return lhs.name == rhs.name
}

public static func < (lhs: GraphQLNamedType, rhs: GraphQLNamedType) -> Bool {
asmundg marked this conversation as resolved.
Show resolved Hide resolved
lhs.name.schemaName < rhs.name.schemaName
}

public var debugDescription: String {
name.schemaName
}
}

public final class GraphQLScalarType: GraphQLNamedType {

Check warning on line 71 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLScalarType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 71 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLScalarType' must restate inherited '@unchecked Sendable' conformance

public let specifiedByURL: String?

Expand Down Expand Up @@ -96,7 +100,7 @@

}

public final class GraphQLEnumType: GraphQLNamedType {

Check warning on line 103 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLEnumType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 103 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLEnumType' must restate inherited '@unchecked Sendable' conformance
public private(set) var values: [GraphQLEnumValue]!

required init(_ jsValue: JSValue, bridge: isolated JavaScriptBridge) {
Expand Down Expand Up @@ -152,7 +156,7 @@

public typealias GraphQLInputFieldDictionary = OrderedDictionary<String, GraphQLInputField>

public final class GraphQLInputObjectType: GraphQLNamedType {

Check warning on line 159 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLInputObjectType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 159 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLInputObjectType' must restate inherited '@unchecked Sendable' conformance
public private(set) var fields: GraphQLInputFieldDictionary!

required init(_ jsValue: JSValue, bridge: isolated JavaScriptBridge) {
Expand Down Expand Up @@ -213,7 +217,7 @@
}
}

public class GraphQLCompositeType: GraphQLNamedType {

Check warning on line 220 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLCompositeType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 220 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLCompositeType' must restate inherited '@unchecked Sendable' conformance
public override var debugDescription: String {
"Type - \(name)"
}
Expand All @@ -229,7 +233,7 @@
}
}

public final class GraphQLObjectType: GraphQLCompositeType, GraphQLInterfaceImplementingType {

Check warning on line 236 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLObjectType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 236 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLObjectType' must restate inherited '@unchecked Sendable' conformance

public private(set) var fields: [String: GraphQLField]!

Expand Down Expand Up @@ -261,10 +265,10 @@
}
}

public class GraphQLAbstractType: GraphQLCompositeType {

Check warning on line 268 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLAbstractType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 268 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLAbstractType' must restate inherited '@unchecked Sendable' conformance
}

public final class GraphQLInterfaceType: GraphQLAbstractType, GraphQLInterfaceImplementingType {

Check warning on line 271 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLInterfaceType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 271 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLInterfaceType' must restate inherited '@unchecked Sendable' conformance

public private(set) var fields: [String: GraphQLField]!

Expand Down Expand Up @@ -296,7 +300,7 @@
}
}

public final class GraphQLUnionType: GraphQLAbstractType {

Check warning on line 303 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen CLI Unit Tests - macOS

class 'GraphQLUnionType' must restate inherited '@unchecked Sendable' conformance

Check warning on line 303 in apollo-ios-codegen/Sources/GraphQLCompiler/GraphQLSchema.swift

View workflow job for this annotation

GitHub Actions / Codegen Lib Unit Tests - macOS

class 'GraphQLUnionType' must restate inherited '@unchecked Sendable' conformance
public let types: [GraphQLObjectType]

required init(_ jsValue: JSValue, bridge: isolated JavaScriptBridge) {
Expand Down
3 changes: 2 additions & 1 deletion apollo-ios-codegen/Sources/IR/IR+Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public final class Schema {
_ types: [GraphQLNamedType],
schemaRootTypes: CompilationResult.RootTypeDefinition
) {
self.allTypes = OrderedSet(types)
// Ensure allTypes is stable
self.allTypes = OrderedSet(types.sorted())
self.schemaRootTypes = schemaRootTypes

var objects = OrderedSet<GraphQLObjectType>()
Expand Down
Loading