Hi,
Is there any way to choose which browser will be used when opening the console with the CLI? A bit like the BROWSER environment variable in create-react-app.
Thanks,
Thibaut
@tibotiber The CLI uses the following programs to open the url on a browser:
OSX: "open"
Windows: "start"
Linux/Other: "xdg-open"
So, depending on your OS, you can change the corresponding settings to make the url open on a different browser. For example on Linux, you can see what the default web browser is by using xdg-settings get default-web-browser and then you can change it using the following command:
xdg-settings set default-web-browser firefox.desktop
Thanks @shahidhk. The idea here is that developers might prefer to use a different browser than their default one for work. For example. I use Firefox for my personal stuff and Firefox developer edition for dev stuff. This allows me to wipe my browser at will for dev without impacting my 芦聽other life聽禄. Would be great to support this.
When I run yarn start on my monorepo, the react dev server starts automatically with the dev browser but Hasura opens on my personal browser at the moment.
I don鈥檛 mind trying my hand at adding this if you guys are keen and can give me some pointers.
That would be great if you can give this a try.
This is where issue the call to open the browser: https://github.com/hasura/graphql-engine/blob/master/cli/commands/console.go#L163
And we use this Go package to do it: https://github.com/skratchdot/open-golang/
The open-golang package is just executing the right command depending on the OS. If you can find out a way to over-ride the browser used for that particular execution, that would be great!
Ah, there seems to be an option to set the program to use:
open.RunWith("https://google.com/", "firefox")
So, we can probably add a new env var HASURA_GRAPHQL_CLI_DEFAULT_BROWSER or something similar to derive this value.
Cool!
So to be honest, I didn't realize the codebase was not gonna be Javascript, my bad 馃槄. I've never done Go before and the syntax looks huuummm.... strange(?)
Nevertheless, would be a cool little challenge for me, but you may have to review a bit more than the average PR haha. Would you point me to a place that reads an environment variable somewhere in the code? I've checked the CLI code a bit but you don't use environment variables here if I'm not mistaken.
I'm travelling right now so probably gonna look into this in a week or two.
@tibotiber Environment variables are read using https://github.com/spf13/viper/
You will need to add a new option to the ExecutionContext at https://github.com/hasura/graphql-engine/blob/master/cli/cli.go#L124-L185 and then assign value from readConfig at https://github.com/hasura/graphql-engine/blob/master/cli/cli.go#L303-L326
Later use the value by changing the function at https://github.com/hasura/graphql-engine/blob/master/cli/commands/console.go#L163 to RunWith
Thanks @shahidhk, super useful pointers. I'll try this soon and post back on progress (or lack thereof 馃槵)
Posted an PR attempt at #3406 :)
Most helpful comment
Posted an PR attempt at #3406 :)