alan-turing-institute / whatwhat

A reimagining of nowwhat in OCaml
MIT License
0 stars 0 forks source link

Look for query templates in a project-relative directory #30

Closed triangle-man closed 1 year ago

triangle-man commented 1 year ago

dune exec whatwhat looks for ./queries/issues-by-project-graphql.graphql relative to the directory in which the command was executed. (So, in particular, you have to be in the top-level of the project directory). We should look "relative to the compiled function".

yongrenjie commented 1 year ago

Since we don't need issues-by-project-graphql.graphql anymore, it's just users.graphql that's left, which is short enough that it can be embedded in the source code without too much of an issue, as done in b262e91.

Additional info just in case anyone needs to revisit this (possibly myself):

dune's suggested mechanism of dealing with this is "sites". The idea is that you specify a set of files which are copied into dune's _build directory when building (or ~/.opam/... when installing), and then in the source code you import a package which tells you where these directories are.

This is a more correct way of dealing with it, and I managed to get it to work, but it

  1. is kind of clunky in terms of dune and dune-project file contents
  2. forces you to call dune build before dune exec -- whatwhat

This is a bit annoying and (imo) opens up potential for confusion. For example, if the graphql file gets updated by someone else and you pull from GitHub but don't do dune build, it will silently use the old version. (Of course, it seems unlikely that this query will ever be updated 😄 but if that's the case then I don't see the problem with hardcoding it as a string anyway.)