# No environment variables in Sandbox

**URL:** <https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892>\
**Category:** GraphOS\
**Tags:** studio\
**Created:** [October 28, 2023, 1:17pm UTC](https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892 "2023-10-28T13:17:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeq](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/mikeq/32/3887_2.png) [@mikeq](https://community.apollographql.com/u/mikeq)\
**Post date:** [October 28, 2023, 1:17pm UTC](https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892/1 "2023-10-28T13:17:47Z")

</div>

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.

 ![image](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/1/1f8137558faa14ea421a1d681e35924198bc0453.png)

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

TIA  
Mike

---

<div class="post-metadata">

**Author:** ![Michelle\_Mabuyo](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michelle_mabuyo/32/80_2.png) [@Michelle\_Mabuyo](https://community.apollographql.com/u/Michelle_Mabuyo)\
**Post date:** [October 30, 2023, 7:58pm UTC](https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892/2 "2023-10-30T19:58:49Z")

</div>

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.

 ![Screenshot 2023-10-30 at 3.56.08 PM](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/0/0208fd9495dc6eb33467e8524a1345cb1f46d85b.png)

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.

---

<div class="post-metadata">

**Author:** ![mikeq](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/mikeq/32/3887_2.png) [@mikeq](https://community.apollographql.com/u/mikeq)\
**Post date:** [October 31, 2023, 7:05am UTC](https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892/3 "2023-10-31T07:05:46Z")

</div>

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

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

Thanks again

---

<div class="post-metadata">

**Author:** ![kool7](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/kool7/32/5269_2.png) [@kool7](https://community.apollographql.com/u/kool7)\
**Post date:** [September 2, 2024, 7:56pm UTC](https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892/4 "2024-09-02T19:56:12Z")

</div>

Hi @Michelle_Mabuyo I am trying to set up variables for my mutation but it is not working all. Attaching screenshot for reference.

 ![Screenshot 2024-09-03 at 1.24.05 AM](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/f/fc0da65e61df1106a6b33f3f1e8ccdd79796d5d7.png)

---

<div class="post-metadata">

**Author:** ![Michelle\_Mabuyo](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/michelle_mabuyo/32/80_2.png) [@Michelle\_Mabuyo](https://community.apollographql.com/u/Michelle_Mabuyo)\
**Post date:** [September 3, 2024, 4:21pm UTC](https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892/5 "2024-09-03T16:21:29Z")

</div>

Hi there @kool7. If you’re working with mutations, you shouldn’t need to open up the pre-operation script modal. In Sandbox, there is a spot for “Variables” in the bottom section. I’ve attached a screenshot with the pink box showing where it is.

 ![Screenshot 2024-09-03 at 12.20.47 PM](https://us1.discourse-cdn.com/flex019/uploads/apollographql/original/2X/9/9184b86ba5ce8f843537d4d019448a3815b1b651.png)

---

<div class="post-metadata">

**Author:** ![Justin\_Gonzalez](https://sea1.discourse-cdn.com/flex019/user_avatar/community.apollographql.com/justin_gonzalez/32/5359_2.png) [@Justin\_Gonzalez](https://community.apollographql.com/u/Justin_Gonzalez)\
**Post date:** [February 6, 2025, 8:48pm UTC](https://community.apollographql.com/t/no-environment-variables-in-sandbox/6892/6 "2025-02-06T20:48:07Z")

</div>

Archived on February 6, 2025, 8:48pm UTC


