Swift: Fix regression for individual files. #1451
Conversation
|
Thanks for making this PR so promptly! const isRedundant = outputIndividualFiles && !!namespace;?
|
…rate file or not, get original tests passing
b1f5229 to
697e93f
Compare
|
@gsabran Guh, good catch - there were a couple things that seem to have not made the bus on my last commit. |
|
I'm gonna take another look at this in the morning before merging - @JacksonKearl let me know if any of the TS looks fishy to you |
| fragments | ||
| } = this.context; | ||
| const isRedundant = !!namespace; | ||
| const isRedundant = !!namespace && !outputIndividualFiles; |
There was a problem hiding this comment.
Isn't the codegen written with extensions when outputIndividualFiles is true? In that case this should be
const isRedundant = !!namespace && outputIndividualFiles;right?
There was a problem hiding this comment.
You're correct that it's written with extensions when outputIndividualFiles is true, but isRedundant should only ever be true if we're not outputting individual files.
If isRedundant is true, codegen omits the public, which is the behavior filed as a bug.
There was a problem hiding this comment.
After figuring out the thing I fucked up, yep, you're right!
| adoptedProtocols.includes("GraphQLFragment") && !!namespace; | ||
| adoptedProtocols.includes("GraphQLFragment") && | ||
| !!namespace && | ||
| !outputIndividualFiles; |
There was a problem hiding this comment.
Same question regarding whether !outputIndividualFiles should be outputIndividualFiles
|
@gsabran I'll wait on your 👍to merge this one - let me know if you have more questions! |
|
public enum MyNameSpace {}
public extension MyNameSpace {
struct Hero: GraphQLFragment { // <- public would be redundant here
public var name: String
public var age: Int
}
}but not for enums as public enum MyNameSpace {
public struct Hero: GraphQLFragment { // <- public is required here
public var name: String
public var age: Int
}
}so I think we should only look for redundancy when the codegen generates extensions, ie when it outputs multiple files. Maybe I'm misunderstanding what |
|
AHA. I think I see where I missed something - the JS |
|
@gsabran better? |
JacksonKearl
left a comment
There was a problem hiding this comment.
Seems reasonable on the TS side, only thing I might add is more documentation around what the parameter is doing, perhaps in the form of some docstrings. As is, I think it could be difficult for someone adding a new feature in the future who need to use one of these functions to know if they should be passing true or false for that parameter.
| classDeclarationForOperation(operation: Operation) { | ||
| classDeclarationForOperation( | ||
| operation: Operation, | ||
| outputIndividualFiles: boolean |
There was a problem hiding this comment.
I'd add a docstring to describe what exactly this parameter is doing (maybe with examples of the difference in output?), because it's not very clear to me just looking at it.
| variant: Variant; | ||
| typeCase?: TypeCase; | ||
| }, | ||
| outputIndividualFiles: boolean, |
…s using `outputIndividualFiles`
|
@gsabran @JacksonKearl Would love 👍s from you guys if you think this is ready to go - would love to get this merged soon so we can put it out with a patch release |
|
thanks for making this change! |
#1449 Pointed out that #1241 introduced a regression when files are being output individually. This PR updates our logic to make sure that information is shared and then fix the issue.