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 OutputFormat not respected #1557

Closed
danpalmer opened this issue Dec 4, 2020 · 4 comments
Closed

Codegen OutputFormat not respected #1557

danpalmer opened this issue Dec 4, 2020 · 4 comments
Labels
codegen Issues related to or arising from code generation
Milestone

Comments

@danpalmer
Copy link

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
@designatednerd
Copy link
Contributor

Option 2 would definitely be better, IMO. I considered option 1 but I felt like it didn't capture intent clearly enough - throwing an error if a folder URL is passed in for singleFile or if a file URL is passed in for multipleFiles seems like a totally reasonable way of enforcing that.

Would definitely welcome a PR!

@designatednerd designatednerd added the codegen Issues related to or arising from code generation label Dec 4, 2020
@designatednerd
Copy link
Contributor

Let me know if you are planning to make a PR - don't want to step on your toes but I should probably close this loophole 😃

@designatednerd
Copy link
Contributor

Check on this has shipped with 0.39.0!

@danpalmer
Copy link
Author

@designatednerd thanks! Sorry for not getting around to doing a PR for this at the time, I have been off for a while. Thanks for going ahead with it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
codegen Issues related to or arising from code generation
Projects
None yet
Development

No branches or pull requests

2 participants