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

Only regenerate Scala files from GraphQL schema if schema changes #92

Open
felixbr opened this issue Sep 3, 2020 · 1 comment
Open

Comments

@felixbr
Copy link
Collaborator

felixbr commented Sep 3, 2020

In our codebase I observed that the generated files are often recompiled without explicitly cleaning them or changing the schema. This isn't a big deal for small schemas but in our case it's over 400 files that are being recompiled and takes several seconds.

I don't have a repro-case yet but it should be fairly straight forward. I can imagine using one of the test/example projects and checking how often the files are being regenerated (it should only happen if the schema changed or after an explicit clean command).

sbt already has facilities to avoid unnecessary work (e.g. used to avoid compiling files that haven't changed), so we should use that here as well imo.

References:
https://www.scala-sbt.org/1.x/docs/Caching.html
https://www.scala-sbt.org/1.x/docs/Cached-Resolution.html

@felixbr felixbr changed the title Only re-generate Scala files from GraphQL schema if schema changes Only regenerate Scala files from GraphQL schema if schema changes Sep 3, 2020
@felixbr
Copy link
Collaborator Author

felixbr commented Apr 22, 2021

So, I've upgraded to 0.16.0 at work and it seems like the incremental compilation is working quite well there already.

My guess is that some of the codegen tasks where rearranged in a way that sbt understands and caches them automatically. From the docs:

sbt will automatically track the outputs of any task that returns one of the following result types: Path, Seq[Path], File or Seq[File].

https://www.scala-sbt.org/1.x/docs/Howto-Track-File-Inputs-and-Outputs.html

I'll see how it goes with the latest version and if everything's working as expected we can close this 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant