Skip to content

Codegen OutputFormat not respected #1557

@danpalmer

Description

@danpalmer

Bug report

Just came across a small sharp edge in the API for codegen – specifying the OutputFormat has no effect, and the output format (single vs multiple files) is only a property of the URL passed in.

This is noted in a comment in the source code, so seems to already be acknowledged as an issue. Given that the API provided affords that this would work in a particular way, and that it doesn't in fact do this, I think it would be good to fix it.

I can see why it would be nice to be able to express the choice in a way that isn't just part of the URL passed in, but the inconsistency means that the documentation aspect can be incorrect, which I think is worse than not having it.

Suggestions

I'd suggest one of two fixes:

  1. Drop the OutputFormat and take a URL, documenting the behaviour given different properties of the URL.
  2. Keep the OutputFormat and raise an exception if the URL passed in doesn't conform to expectations.

I think it's nice to have the documentation in the API, and maintaining backwards compatibility is always good, so I'd have a preference for option 2. This exception would also not technically break backwards compatibility as I think the compatibility is framed in terms of documentation rather than behaviour, but please do correct me on this if I'm wrong!

Contributions

Would you accept a PR for this? Can we treat this issue as a design discussion for that contribution?

Versions

  • apollo-ios SDK version: 0.34.1
  • Xcode version: 12.3
  • Swift version: 5.3
  • Package manager: SPM

Metadata

Metadata

Assignees

No one assigned

    Labels

    codegenIssues related to or arising from code generation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions