No environment variables in Sandbox

Hi,

I am using the Explorer Sandbox with a local supergraph, I have defined Environment Variables in my settings (I can use them directly in query operations so they are definitely setup).

When I try to get an environment variable in a preflight script it cannot find then and just returns undefined.

Is this a limitation of the Sandbox Explorer? Do I need to have a paid account and have my schemas hosted?

TIA
Mike

Hey there @mikeq !

When testing the preflight script, you’ll need to include the environment variables on the bottom right section as well. I attached a screenshot where I have it working. The first console log was without the environment variables set. The second log was with the variable set.

As you mentioned, you already set up your environment variables in Settings, so that should be good to go. But for the “Edit your Preflight Script” modal, you do need to set them there as well, for testing purposes.

Hope that helps.

Ah, thanks for your help @MichelleMabuyo , that does indeed help.

I mistakenly thought it would pull through my environment variables for testing. All is working now.

Thanks again

1 Like