craftcms / gatsby-source-craft

Gatsby source plugin for Craft CMS.
MIT License
54 stars 13 forks source link

Allow `CRAFTGQL_URL` to be set via config option #13

Closed kara-todd closed 3 years ago

kara-todd commented 3 years ago

Description

Vercel doesn't support branch environment variables. Instead, there are only 3 default environments "Live", "Preview" and "Local"

Their recommend approach to set per-branch environment variables is to do something like following:

const host =
  process.env.VERCEL_GITHUB_COMMIT_REF === "qa"
    ? process.env.CRAFTGQL_QA_URL
    : process.env.CRAFTGQL_URL;

Unfortunately, this isn't currently supported as CRAFTGQL_URL is hard-coded in the plugin file. I think simply moving this to an override-able option using the environment as a default would solve the issue.