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

Pruning generated files for .relative(subpath:) operations deletes only #2969

Closed
jimisaacs opened this issue Apr 20, 2023 · 8 comments · Fixed by #2994
Closed

Pruning generated files for .relative(subpath:) operations deletes only #2969

jimisaacs opened this issue Apr 20, 2023 · 8 comments · Fixed by #2994
Assignees
Labels
bug Generally incorrect behavior planned-next Slated to be included in the next release

Comments

@jimisaacs
Copy link
Contributor

Summary

When generating code with operations: .relative(subpath: "somepath"), and with pruneGeneratedFiles not set (assuming defaulting to true), the after 1 generate run it only deletes the operations. Then after a second run it regenerates them.

If you repeat this process it should repeat the pattern, i.e. delete only -> regenerate -> delete only -> regenerate -> etc.

Version

1.0.7

Steps to reproduce the behavior

Create a codegen project with operations: .relative(subpath: "somepath"), and with pruneGeneratedFiles not set, then repeatedly execute codegen. You should see the operations be deleted and regenerated on each subsequent execution.

Logs

No response

Anything else?

No response

@jimisaacs jimisaacs added bug Generally incorrect behavior needs investigation labels Apr 20, 2023
@AnthonyMDev
Copy link
Contributor

Ooooh! Thanks for this @jimisaacs! We definitely will look into it.

@AnthonyMDev AnthonyMDev added this to the Patch Releases (1.1.x) milestone Apr 20, 2023
@calvincestari
Copy link
Member

Huh! We've struggled to be able to replicate this behaviour in the past - thank you for narrowing it down to a particular configuration setting @jimisaacs!

@calvincestari calvincestari added the planned-next Slated to be included in the next release label May 1, 2023
@BobaFetters
Copy link
Member

@jimisaacs I am investigating the issue currently, and wondering if you could provide a little more info about your setup. Are any of the paths in your file structure Symlinks to another path? Possibly the "subpath" given in the operations: .relative(subpath: "somepath") or maybe some higher in the directory structure?

@jimisaacs
Copy link
Contributor Author

@BobaFetters no symlinks, just a subpath that ends up in the Sources of multiple swift packages.

@BobaFetters
Copy link
Member

@jimisaacs Would you be able to provide a small sample setup that replicates what you have in your project with the subpath and a swift package that uses that in its Sources to be able to test against? This would help in verifying the cause of the issue and ensuring the fix covers all use cases.

@jimisaacs
Copy link
Contributor Author

jimisaacs commented May 3, 2023

@BobaFetters here you go! If you do this...

cd ReducedCase/librares/Codegen
swift run

Or...

open ReducedCase/ReducedCase/ReducedCase.xcworkspace

then run GraphQLCodegenExe from within Xcode.

Both should alternate removing and creating generated files upon repeated execution.
apollo-ReducedCase.zip

@BobaFetters
Copy link
Member

@jimisaacs Thanks so much for providing that! I believe I have a fix for the issue, few more tests to run to verify for sure, but this is super helpful.

@BobaFetters
Copy link
Member

The fix for this has been merged into main and will go out in our next release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Generally incorrect behavior planned-next Slated to be included in the next release
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants