Environment Variables

Environment variables are key/value pairs that are set outside your source code. The variable value can change depending on the deployment environment.

All values are encrypted and stored as strings.

You can create an environment variable with the same name in Production or Preview environments.

  • Production
    Environment variables set with the Production context are only available in the production environment.
  • Preview
    Environment variables set with the Preview context are only available in preview environments.
  1. Navigate to the dashboard for your project,
  2. Select the Settings tab,
  3. Select the Environment Variables tab,
  4. Enter a name and a value.

Grafbase CLI does not detect any environment variable set through the Dashboard. However, you can specify an environment variable for local development within the file grafbase/.env:

Create the file .env in the grafbase folder and add a key/value pair like the following:

export NAME=VALUE

You can access environment variables inside grafbase/schema.graphql using double curly brackets. You must prefix environment variable names with env., as shown in the following example, which sets your authentication provider issuer using the environment variable ISSUER_URL:

import { auth, config, graph } from '@grafbase/sdk' const g = graph.Standalone() const provider = auth.OpenIDConnect({ issuer: '{{ env.ISSUER_URL }}', }) export default config({ graph: g, auth: { providers: [provider], }, })
  • Environment variables are case-insensitive
  • Environment variables cannot start with GRAFBASE_
  • Environment variable names can be up to 255 characters
  • Environment variable values can be up to 5000 characters
  • Environment variable values are always treated as strings
Was this page helpful?