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

only output operation manifest once #3225

Merged
merged 1 commit into from
Sep 18, 2023
Merged
Changes from all commits
Commits
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
28 changes: 13 additions & 15 deletions Sources/ApolloCodegenLib/ApolloCodegen.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,6 @@ public class ApolloCodegen {
try validate(configContext, with: compilationResult)

let ir = IR(compilationResult: compilationResult)

if itemsToGenerate.contains(.operationManifest) {
var operationIDsFileGenerator = OperationManifestFileGenerator(config: configContext)

for operation in compilationResult.operations {
autoreleasepool {
let irOperation = ir.build(operation: operation)
operationIDsFileGenerator?.collectOperationIdentifier(irOperation)
}
}

try operationIDsFileGenerator?.generate(fileManager: fileManager)
}

if itemsToGenerate.contains(.code) {
var existingGeneratedFilePaths = configuration.options.pruneGeneratedFiles ?
Expand All @@ -165,6 +152,15 @@ public class ApolloCodegen {
afterCodeGenerationUsing: fileManager
)
}
} else if itemsToGenerate.contains(.operationManifest) {
var operationIDsFileGenerator = OperationManifestFileGenerator(config: configContext)
for operation in compilationResult.operations {
autoreleasepool {
let irOperation = ir.build(operation: operation)
operationIDsFileGenerator?.collectOperationIdentifier(irOperation)
}
}
try operationIDsFileGenerator?.generate(fileManager: fileManager)
}
}

Expand Down Expand Up @@ -435,7 +431,10 @@ public class ApolloCodegen {
}
}

var operationIDsFileGenerator = OperationManifestFileGenerator(config: config)
var operationIDsFileGenerator: OperationManifestFileGenerator?
if itemsToGenerate.contains(.operationManifest) {
operationIDsFileGenerator = OperationManifestFileGenerator(config: config)
}

for operation in compilationResult.operations {
try autoreleasepool {
Expand All @@ -453,7 +452,6 @@ public class ApolloCodegen {
if itemsToGenerate.contains(.operationManifest) {
try operationIDsFileGenerator?.generate(fileManager: fileManager)
}
operationIDsFileGenerator = nil

for graphQLObject in ir.schema.referencedTypes.objects {
try autoreleasepool {
Expand Down