The way that I ended up doing this was using the current git tag rather than the npm package version. I was comfortable with this because I didn’t want to have to maintain different version numbers for the different sides of the application or anything like that, and this ended up just being easier.
Basically I changed my start command for my API to look like this, in the root package.json
file:
"start:api": "APP_VERSION=\"$(git describe --tag --abbrev=0)\" yarn rw deploy flightcontrol api --serve"
Then I added a graphql query called version
, the implementation for which looks like this:
export const version: QueryResolvers['version'] = () => {
return process.env.APP_VERSION
}
Then use that query wherever I want to display the version in the UI. I’m sure there are some slightly better ways to do this, but this works for my needs. Hopefully this helps someone at least get started if they want to do something similar!