Closed ghost closed 1 year ago
Could you elaborate on the project's development lifecycle with elm/graphql? I have no idea about what can be supported by vite-plugin-elm. codegen part is done by just running the CLI command, and then Elm project should be rebuilt? If so, we can configure watching generated code to trigger...?
It'd be nice if you give a sample project to see how this plugin can help!
On the current project that I work on, we have a few phases to our backend build, one of those steps generates a graphql schema file.
Our front end build consists of two manual steps and then a webpack watcher (soon to be vite), which produces an asset which our phoenix backend serves with live reload.
Manual step 1 - combine our generic elm app with a locale specific translations module Manual step 2 - invoke elm/graphql generator ( "node_modules/.bin/elm-graphql --introspection-file ../schema.json --base Api --scalar-codecs ApiScalarCodecs --output elm" )
Webpack watcher uses elm-webpack-loader to compile elm.
I'm hoping when we move to vite, that we can combine manual step 2 with the watcher, either using extra configuration in this elm vite plugin or through an additional elm-graphql plugin. Either way, the automation of running elm-graphql could incorporate some intelligence to determine if the schema file has changed and elm-graphql generator needs to be run or can be skipped.
I see. Probably, it's out of vite-plugin-elm's scope I think.
vite-plugin-run may be helpful to run elm-graphql
with specific condition like every changing of schema.json
. Then vite-plugin-elm catches the change of .elm
files for rebuild.
Thanks for the pointer!
I may re-open in about six months, after trying out vite-plugin-run, if I find that more coordination between completion of graphql generation command and start of elm compiler is desirable.
I'm curious if you would implement adding calling elm/graphql's code gen as part of this plugin or recommend defining a second vite plugin which performed that task and defined a proper ordering between the two plugins?