Skip to content

Swift Codegen Not Respecting --mergeInFieldsFromFragmentSpreads Flag #537

@alex-king-ck

Description

@alex-king-ck

Using CLI version 0.2.0 (The latest version supported by apollo-ios)
The same issue is present when using 0.6.0 (latest current version)

We're trying to upgrade our version of apollo-ios. This means updating our version of the CLI (coming from apollo-codegen v0.17). Generating our API.swift file with all of our queries produced a 180MB file. We had seen this previously and the resolution was to disable merging fields from fragment spreads. However, the output of apollo-cli 0.2.0 doesn't change when we use the --mergeInFieldsFromFragmentSpreads flag.

Here is a small sample query that can be used to illustrate the issue:

query Hub($useForce: Boolean) {
    hubsInfo(useForce: $useForce) {
        hubs {
            ...hubInfo
        }
    }
}

fragment hubInfo on Hub {
    discriminator
    label {
    ...formattedTextInfo
    }
}


fragment formattedTextInfo on FormattedText {
    spans {
        text
        format {
            italic
            strong
        }
    }
}

Generating using apollo-cli v0.6.0 with and without --mergeInFieldsFromFragmentSpreads produced the following output:
API.swift.txt

Here is the expected output, generated with apollo-codegen v0.17:
API.swift.txt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions