diff --git a/Tests/ApolloCodegenTests/CodeGenIR/IRInputObjectTests.swift b/Tests/ApolloCodegenTests/CodeGenIR/IRInputObjectTests.swift index 19c3123c0..e5b81d427 100644 --- a/Tests/ApolloCodegenTests/CodeGenIR/IRInputObjectTests.swift +++ b/Tests/ApolloCodegenTests/CodeGenIR/IRInputObjectTests.swift @@ -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] } // MARK: - Tests diff --git a/apollo-ios-codegen/Sources/IR/IR+Schema.swift b/apollo-ios-codegen/Sources/IR/IR+Schema.swift index 87d73e7c7..f459630ce 100644 --- a/apollo-ios-codegen/Sources/IR/IR+Schema.swift +++ b/apollo-ios-codegen/Sources/IR/IR+Schema.swift @@ -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(by: { $0.name.schemaName < $1.name.schemaName })) self.schemaRootTypes = schemaRootTypes var objects = OrderedSet()