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

Codegen async/await Mega PR #57

Merged
merged 100 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
18ef1ca
Updating apollo-ios-codegen to main
BobaFetters Aug 24, 2023
7072f46
Adding test location note to subtrees (apollographql/apollo-ios-dev#27)
BobaFetters Aug 31, 2023
48b6461
Updating contributing guides (apollographql/apollo-ios-dev#23)
BobaFetters Sep 1, 2023
94ef89e
split: apollo-ios-codegen - Updating READMEs and ci workflow name (ap…
BobaFetters Sep 1, 2023
4a5f45b
Updating to current main (apollographql/apollo-ios-dev#32)
BobaFetters Sep 12, 2023
a3d2ce4
Break out GraphQLCompiler and TemplateString (apollographql/apollo-io…
AnthonyMDev Sep 15, 2023
b5e0cf1
Breakout Codegen IR to separate module (apollographql/apollo-ios-dev#37)
AnthonyMDev Sep 18, 2023
c4f7eaa
Add referencedFragments to CompilationResult (apollographql/apollo-io…
AnthonyMDev Sep 20, 2023
ceea2e8
Adding ci to auto close PRs (apollographql/apollo-ios-dev#41)
BobaFetters Sep 22, 2023
c6d829c
Updating to latest main from apollo-ios (apollographql/apollo-ios-dev…
BobaFetters Sep 25, 2023
134524a
Readding missing imports (apollographql/apollo-ios-dev#43)
BobaFetters Sep 25, 2023
0fc178e
Attempt CI fix
AnthonyMDev Sep 18, 2023
2ba5fd3
Attempt CI fix
AnthonyMDev Sep 18, 2023
24a96e5
Fix Package build error
AnthonyMDev Sep 18, 2023
d03d45e
Fix Package build error
AnthonyMDev Sep 18, 2023
f3eaa97
whitespace
AnthonyMDev Sep 18, 2023
751f962
whitespace
AnthonyMDev Sep 18, 2023
14bcf17
Make OperationIdentifierFactory take provider closure
AnthonyMDev Sep 19, 2023
95f04b5
Make OperationIdentifierFactory take provider closure
AnthonyMDev Sep 19, 2023
f71aa53
OperationIdentifierProvider error handling
AnthonyMDev Sep 19, 2023
36069f9
OperationIdentifierProvider error handling
AnthonyMDev Sep 19, 2023
23434a1
Refactor Operation Manifest and OperationDescription
AnthonyMDev Sep 19, 2023
fae5b9f
Refactor Operation Manifest and OperationDescription
AnthonyMDev Sep 19, 2023
c9134c2
Refactor Codegen to use an instance of itself
AnthonyMDev Sep 20, 2023
106b76d
Refactor Codegen to use an instance of itself
AnthonyMDev Sep 20, 2023
84cf15d
WIP: Make codegen async
AnthonyMDev Sep 20, 2023
a998846
WIP: Make codegen async
AnthonyMDev Sep 20, 2023
43b082e
Get minimal async codegen building.
AnthonyMDev Sep 22, 2023
1b6072c
Get minimal async codegen building.
AnthonyMDev Sep 22, 2023
ae37924
WIP: getting unit tests running.
AnthonyMDev Sep 22, 2023
67aa468
WIP: getting unit tests running.
AnthonyMDev Sep 22, 2023
391804e
Add idProvider parameter to public build function
AnthonyMDev Sep 22, 2023
12f9e3a
Add idProvider parameter to public build function
AnthonyMDev Sep 22, 2023
541500b
minor fix
AnthonyMDev Sep 22, 2023
c60625c
minor fix
AnthonyMDev Sep 22, 2023
4679f40
Unit tests building
AnthonyMDev Sep 26, 2023
efa8edb
Unit tests building
AnthonyMDev Sep 26, 2023
9f803c2
Test updates
AnthonyMDev Sep 26, 2023
b62c239
Fix formatting of operation identifier raw source text
AnthonyMDev Sep 26, 2023
b57ad70
Fix formatting of operation identifier raw source text
AnthonyMDev Sep 26, 2023
fb5a5bf
Adding issue callout to Readme (apollographql/apollo-ios-dev#51)
BobaFetters Sep 28, 2023
5069eb3
WIP: Restructure Javascript Swift Wrappers for async
AnthonyMDev Sep 28, 2023
5dd3995
WIP: Restructure Javascript Swift Wrappers for async
AnthonyMDev Sep 28, 2023
bf3958c
Make codegen engine call javascript asynchronously
AnthonyMDev Oct 2, 2023
3f87342
Make codegen engine call javascript asynchronously
AnthonyMDev Oct 2, 2023
96b6a5c
Refactor test infra for async
AnthonyMDev Oct 2, 2023
f892d20
Refactor test infra for async
AnthonyMDev Oct 2, 2023
84674b9
WIP: Updating tests to use async
AnthonyMDev Oct 2, 2023
1f112e4
Got unit tests running (not passing)
AnthonyMDev Oct 2, 2023
e667b83
WIP: Fixing bugs with async JavaScript Bridge
AnthonyMDev Oct 3, 2023
766a23e
WIP: Fixing bugs with async JavaScript Bridge
AnthonyMDev Oct 3, 2023
c708785
chore(deps): pin dependencies (#5)
svc-secops Oct 3, 2023
8fabdf3
Fix bug for merged documents not having source
AnthonyMDev Oct 3, 2023
92e7514
Fix bug for merged documents not having source
AnthonyMDev Oct 3, 2023
a72e598
Fix type to union map data race
AnthonyMDev Oct 3, 2023
3b9c610
Fix type to union map data race
AnthonyMDev Oct 3, 2023
062132e
Fix all data races
AnthonyMDev Oct 3, 2023
6166225
Fix all data races
AnthonyMDev Oct 3, 2023
7757c37
Fix error source location parsing
AnthonyMDev Oct 3, 2023
1abfd36
Fix error source location parsing
AnthonyMDev Oct 3, 2023
e1a8833
Bug fix
AnthonyMDev Oct 3, 2023
dc51625
Bug fix
AnthonyMDev Oct 3, 2023
567f38c
More bug fixes
AnthonyMDev Oct 3, 2023
8f9b7b3
More bug fixes
AnthonyMDev Oct 3, 2023
92b72b6
Make FileManager async to fix data race
AnthonyMDev Oct 3, 2023
a23d172
Make FileManager async to fix data race
AnthonyMDev Oct 3, 2023
d46aeea
Bug fix
AnthonyMDev Oct 3, 2023
84d0079
Bug fix
AnthonyMDev Oct 3, 2023
21e61e4
Bug fix
AnthonyMDev Oct 3, 2023
85deefb
Bug fix
AnthonyMDev Oct 3, 2023
1872445
bug fix
AnthonyMDev Oct 3, 2023
b6ebe25
Fix broken test
AnthonyMDev Oct 3, 2023
55bef8d
Merge remote-tracking branch 'origin/main' into codegen-custom-operat…
AnthonyMDev Oct 3, 2023
72cbe25
Merge remote-tracking branch 'origin/main' into codegen-custom-operat…
AnthonyMDev Oct 3, 2023
5c8d9c2
Update codegen CLI to use async/await
AnthonyMDev Oct 4, 2023
be879af
Update codegen CLI to use async/await
AnthonyMDev Oct 4, 2023
2b39445
Make cli executable main entry point use AsyncParsableCommand
AnthonyMDev Oct 4, 2023
199295c
Make cli executable main entry point use AsyncParsableCommand
AnthonyMDev Oct 4, 2023
58e0354
Update cli to use @main
AnthonyMDev Oct 4, 2023
165f6f8
Update cli to use @main
AnthonyMDev Oct 4, 2023
a90c954
Subtree updates (apollographql/apollo-ios-dev#58)
BobaFetters Oct 4, 2023
43400ba
pull: apollo-ios-codegen - PR #59 - Updating subtree ci with pull com…
Oct 4, 2023
fce1a21
Release 1.6.0 (apollographql/apollo-ios-dev#67)
BobaFetters Oct 6, 2023
908fd7e
Merge remote-tracking branch 'origin/main' into codegen-custom-operat…
AnthonyMDev Oct 12, 2023
e7567e0
Merge remote-tracking branch 'origin/main' into codegen-custom-operat…
AnthonyMDev Oct 12, 2023
a971139
Inject network session for schema download (#1)
jimisaacs Oct 12, 2023
6b1dcc0
Merge commit 'a971139faeae01aaf77dee847c2308efb6afd24e' into codegen-…
AnthonyMDev Oct 12, 2023
e4cf9f2
Fix CLI tests for session injection in mocks
AnthonyMDev Oct 12, 2023
f03ebab
Implement ConcurrentCompactMap utility
AnthonyMDev Oct 12, 2023
4b2e74b
Isolate output folder for codgen unit tests
AnthonyMDev Oct 12, 2023
c84d995
Removing invalid tests
AnthonyMDev Oct 12, 2023
11bbda7
Fix server integration tests
AnthonyMDev Oct 12, 2023
5df0a2f
More test fixes!
AnthonyMDev Oct 12, 2023
2ad2390
Merge remote-tracking branch 'origin/main' into codegen-custom-operat…
AnthonyMDev Oct 12, 2023
52e87ec
Sendable usage corrections
AnthonyMDev Oct 23, 2023
6218e97
Make JavaScriptBridge run on main thread executor
AnthonyMDev Oct 23, 2023
11b6456
Make JavaScriptBridge use weak references to JSValues
AnthonyMDev Oct 23, 2023
20d22a0
Make JavaScriptBridge use ObjectIdentifiers to JSValues
AnthonyMDev Oct 23, 2023
2c4fc8c
Apply suggestions from code review
AnthonyMDev Oct 26, 2023
e6a12a1
Final clean up
AnthonyMDev Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions .package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "1f3bde57bde12f5e7b07909848c071e9b73d6edc",
"version" : "10.0.0"
"revision" : "edaedc1ec86f14ac6e2ca495b94f0ff7150d98d0",
"version" : "12.3.0"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let project = Project(
name: "ApolloDev",
organizationName: "apollographql",
packages: [
.package(url: "https://github.com/Quick/Nimble.git", from: "10.0.0"),
.package(url: "https://github.com/Quick/Nimble.git", from: "12.3.0"),
.package(path: "apollo-ios"),
.package(path: "apollo-ios-codegen"),
.package(path: "apollo-ios-pagination"),
Expand Down
23 changes: 23 additions & 0 deletions Tests/ApolloCodegenInternalTestHelpers/AsyncMap.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import Foundation

extension Sequence {
public func asyncMap<T>(
_ transform: (Element) async throws -> T
) async rethrows -> [T] {
var values = [T]()

for element in self {
try await values.append(transform(element))
}

return values
}

public func asyncForEach(
_ body: (Element) async throws -> Void
) async rethrows {
for element in self {
try await body(element)
}
}
}
68 changes: 0 additions & 68 deletions Tests/ApolloCodegenInternalTestHelpers/CodegenTestHelper.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ extension GraphQLJSFrontend {
schema: String,
document: String,
config: ApolloCodegen.ConfigurationContext
) throws -> CompilationResult {
let schemaSource = try makeSource(schema, filePath: "")
let documentSource = try makeSource(document, filePath: "")
) async throws -> CompilationResult {
async let schemaSource = try makeSource(schema, filePath: "")
async let documentSource = try makeSource(document, filePath: "")

let schema = try loadSchema(from: [schemaSource])
let document = try parseDocument(
let schema = try await loadSchema(from: [schemaSource])
let document = try await parseDocument(
documentSource,
experimentalClientControlledNullability: config.experimentalFeatures.clientControlledNullability
)

return try compile(
return try await compile(
schema: schema,
document: document,
validationOptions: ValidationOptions(config: config)
Expand All @@ -29,11 +29,11 @@ extension GraphQLJSFrontend {
schema: String,
document: String,
enableCCN: Bool = false
) throws -> CompilationResult {
) async throws -> CompilationResult {
let config = ApolloCodegen.ConfigurationContext(
config: .mock(experimentalFeatures: .init(clientControlledNullability: enableCCN)))

return try compile(
return try await compile(
schema: schema,
document: document,
config: config
Expand All @@ -44,20 +44,36 @@ extension GraphQLJSFrontend {
schema: String,
documents: [String],
config: ApolloCodegen.ConfigurationContext
) throws -> CompilationResult {
let schemaSource = try makeSource(schema, filePath: "")
let schema = try loadSchema(from: [schemaSource])

let documents: [GraphQLDocument] = try documents.enumerated().map {
let source = try makeSource($0.element, filePath: "Doc_\($0.offset)")
return try parseDocument(
source,
) async throws -> CompilationResult {
async let schemaSource = try makeSource(schema, filePath: "")

let sources: [GraphQLSource] = try await documents.enumerated().asyncMap {
try await makeSource($0.element, filePath: "Doc_\($0.offset)")
}

return try await compile(
schema: schemaSource,
definitions: sources,
config: config
)
}

public func compile(
schema schemaSource: GraphQLSource,
definitions: [GraphQLSource],
config: ApolloCodegen.ConfigurationContext
) async throws -> CompilationResult {
let schema = try await loadSchema(from: [schemaSource])

let documents: [GraphQLDocument] = try await definitions.asyncMap {
return try await parseDocument(
$0,
experimentalClientControlledNullability: config.experimentalFeatures.clientControlledNullability
)
}

let mergedDocument = try mergeDocuments(documents)
return try compile(
let mergedDocument = try await mergeDocuments(documents)
return try await compile(
schema: schema,
document: mergedDocument,
validationOptions: ValidationOptions(config: config)
Expand All @@ -68,11 +84,11 @@ extension GraphQLJSFrontend {
schema: String,
documents: [String],
enableCCN: Bool = false
) throws -> CompilationResult {
) async throws -> CompilationResult {
let config = ApolloCodegen.ConfigurationContext(
config: .mock(experimentalFeatures: .init(clientControlledNullability: enableCCN)))

return try compile(
return try await compile(
schema: schema,
documents: documents,
config: config
Expand All @@ -83,16 +99,16 @@ extension GraphQLJSFrontend {
schemaJSON: String,
document: String,
config: ApolloCodegen.ConfigurationContext
) throws -> CompilationResult {
let documentSource = try makeSource(document, filePath: "")
let schemaSource = try makeSource(schemaJSON, filePath: "schema.json")
let schema = try loadSchema(from: [schemaSource])
let document = try parseDocument(
) async throws -> CompilationResult {
async let documentSource = try makeSource(document, filePath: "")
async let schemaSource = try makeSource(schemaJSON, filePath: "schema.json")

let schema = try await loadSchema(from: [schemaSource])
let document = try await parseDocument(
documentSource,
experimentalClientControlledNullability: config.experimentalFeatures.clientControlledNullability)

return try compile(
return try await compile(
schema: schema,
document: document,
validationOptions: ValidationOptions(config: config)
Expand All @@ -103,11 +119,11 @@ extension GraphQLJSFrontend {
schemaJSON: String,
document: String,
enableCCN: Bool = false
) throws -> CompilationResult {
) async throws -> CompilationResult {
let config = ApolloCodegen.ConfigurationContext(
config: .mock(experimentalFeatures: .init(clientControlledNullability: enableCCN)))

return try compile(
return try await compile(
schemaJSON: schemaJSON,
document: document,
config: config
Expand Down
30 changes: 15 additions & 15 deletions Tests/ApolloCodegenInternalTestHelpers/IR+Mocking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ extension IRBuilder {
schema: String,
document: String,
enableCCN: Bool = false
) throws -> IRBuilder {
let frontend = try GraphQLJSFrontend()
let compilationResult = try frontend.compile(
) async throws -> IRBuilder {
let frontend = try await GraphQLJSFrontend()
let compilationResult = try await frontend.compile(
schema: schema,
document: document,
enableCCN: enableCCN
Expand All @@ -24,9 +24,9 @@ extension IRBuilder {
schema: String,
documents: [String],
enableCCN: Bool = false
) throws -> IRBuilder {
let frontend = try GraphQLJSFrontend()
let compilationResult = try frontend.compile(
) async throws -> IRBuilder {
let frontend = try await GraphQLJSFrontend()
let compilationResult = try await frontend.compile(
schema: schema,
documents: documents,
enableCCN: enableCCN
Expand All @@ -38,18 +38,17 @@ extension IRBuilder {
schemaJSON: String,
document: String,
enableCCN: Bool = false
) throws -> IRBuilder {
let frontend = try GraphQLJSFrontend()
let compilationResult = try frontend.compile(
) async throws -> IRBuilder {
let frontend = try await GraphQLJSFrontend()
let compilationResult = try await frontend.compile(
schemaJSON: schemaJSON,
document: document,
enableCCN: enableCCN
)
return .mock(compilationResult: compilationResult)
}

public static func mock(
schemaNamespace: String = "TestSchema",
public static func mock(
compilationResult: CompilationResult
) -> IRBuilder {
return IRBuilder(compilationResult: compilationResult)
Expand All @@ -62,7 +61,7 @@ extension IR.NamedFragment {
public static func mock(
_ name: String,
type: GraphQLCompositeType = .mock("MockType"),
source: String? = nil
source: String = ""
) -> IR.NamedFragment {
let definition = CompilationResult.FragmentDefinition.mock(name, type: type, source: source)
let rootField = CompilationResult.Field.mock(name, type: .entity(type))
Expand All @@ -79,7 +78,7 @@ extension IR.NamedFragment {
.descriptor(
forType: type,
inclusionConditions: nil,
givenAllTypesInSchema: .init([type])
givenAllTypesInSchema: .init([type], schemaRootTypes: .mock())
))))

return IR.NamedFragment(
Expand Down Expand Up @@ -111,7 +110,7 @@ extension IR.Operation {
scopePath: [.descriptor(
forType: .mock(),
inclusionConditions: nil,
givenAllTypesInSchema: .init([]))
givenAllTypesInSchema: .init([], schemaRootTypes: .mock()))
])
),
referencedFragments: referencedFragments
Expand All @@ -127,7 +126,8 @@ extension IR.Operation {
let definition = CompilationResult.OperationDefinition.mock(
name: name,
type: type,
source: source
source: source,
referencedFragments: referencedFragments.map(\.definition)
)

return IR.Operation.mock(definition: definition, referencedFragments: referencedFragments)
Expand Down