Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ApolloServer GraphQL Playground not necessarily turned off in production #1591

Closed
dthyresson opened this issue Dec 24, 2020 · 6 comments · Fixed by #1655
Closed

ApolloServer GraphQL Playground not necessarily turned off in production #1591

dthyresson opened this issue Dec 24, 2020 · 6 comments · Fixed by #1655
Labels
bug/confirmed We have confirmed this is a bug topic/api
Milestone

Comments

@dthyresson
Copy link
Contributor

dthyresson commented Dec 24, 2020

While

export const createGraphQLHandler = ({

does turn off the playground if in dev mode, because it relies on process.env.NODE_ENV

process.env.NODE_ENV !== 'production'

and this may not be set in Netlify, the GraphQL playground could be exposed.

export const createGraphQLHandler = ({
  context,
  getCurrentUser,
  onException,
  cors,
  onHealthCheck,
  ...options
}: GraphQLHandlerOptions = {}) => {
  const isDevEnv = process.env.NODE_ENV !== 'production'
  const handler = new ApolloServer({
    // Turn off playground, introspection and debug in production.
    debug: isDevEnv,
    introspection: isDevEnv,
    playground: isDevEnv,

How to fix?

  • make sure process.env.NODE_ENV is set? (edit: nope ...)
  • be explicit and have GRAPHQL_PLAYGROUND_ENABLED env set only in dev and check that value for enabling the playground

Notes:

https://community.netlify.com/t/node-env-is-undefined-in-lambda-functions-no-matter-what-i-do/20667/2

Issue at hand is the Netlify Build vs Runtime environment. You will have to explicitly set NODE_ENV as a Netlify environment variable in their admin UI.

@dthyresson dthyresson added bug/confirmed We have confirmed this is a bug topic/api labels Dec 24, 2020
@dthyresson
Copy link
Contributor Author

Turns out that

make sure process.env.NODE_ENV is set?

May not be an option.

Setting this caused my Netlify builds to fail.

9:32:54 AM: ❯ Context
9:32:54 AM:   production
9:32:54 AM: ​
9:32:54 AM: ────────────────────────────────────────────────────────────────
9:32:54 AM:   1. build.command from netlify.toml                            
9:32:54 AM: ────────────────────────────────────────────────────────────────
9:32:54 AM: ​
9:32:54 AM: $ yarn rw build && yarn rw db up --no-db-client --auto-approve
9:32:54 AM: yarn run v1.22.4
9:32:54 AM: error Command "rw" not found.

@thedavidprice thedavidprice added this to the v1.0 milestone Jan 13, 2021
@Tobbe
Copy link
Member

Tobbe commented Jan 17, 2021

How about we change to const isDevEnv = process.env.NODE_ENV === 'development'?

@peterp
Copy link
Contributor

peterp commented Jan 17, 2021

@Tobbe Super reasonable solution, ship it!

@dthyresson I do believe that Netlify's runtime boots up Lambda functions as production. We could add a Redwood schema and service that shares this information.

@dthyresson
Copy link
Contributor Author

@peterp > I do believe that Netlify's runtime boots up Lambda functions as production.

If it does, then it isn't there:

I asked in the Netlify community some time ago:

https://community.netlify.com/t/are-envs-set-in-build-plugins-available-during-function-runtime/18842

And they responded:

At the moment, the only environment variables available in Netlify Functions at runtime are the ones specified in the Netlify app UI. Environment variables set in netlify.toml or set inside a Build plugin with process.env.name = value are not available there unfortunately.

So, I take that to mean that NODE_ENV is undefined when running a lambda function -- and that is what we (and others) see.

We could add a Redwood schema and service that shares this information.

Sorry, I don't understand what you mean by: "Redwood schema and service that shares this information"

@dthyresson
Copy link
Contributor Author

Oh, I was chatting with Tobbe and was looking at a different issue and just now realized this was the graphql issue -- so ..

"Redwood schema and service that shares this information"

Assume mean in https://github.com/redwoodjs/redwood/blob/main/packages/api/src/makeMergedSchema/rootSchema.ts:

 Query: {
    redwood: () => ({
      version: apiPackageJson.version as string,
      prismaVersion: () => prismaVersion.client,
      currentUser: (_args: any, context: GlobalContext) => {
        return context?.currentUser
      },
    }),

to add the current deployed environment here?

@Tobbe
Copy link
Member

Tobbe commented Jan 17, 2021

How about we change to const isDevEnv = process.env.NODE_ENV === 'development'?

Actually this wouldn't work yet, because NODE_ENV is undefined on localhost too. But I've fixed that in #1653 So when that lands I can PR this fix too

jtoar pushed a commit that referenced this issue Oct 26, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [react-player](https://togithub.com/CookPete/react-player) | [`2.12.0`
->
`2.13.0`](https://renovatebot.com/diffs/npm/react-player/2.12.0/2.13.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-player/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-player/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-player/2.12.0/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-player/2.12.0/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>CookPete/react-player (react-player)</summary>

###
[`v2.13.0`](https://togithub.com/CookPete/react-player/blob/HEAD/CHANGELOG.md#v2130)

[Compare
Source](https://togithub.com/CookPete/react-player/compare/v2.12.0...v2.13.0)

- Fix
[#&#8203;1604](https://togithub.com/CookPete/react-player/issues/1604) -
FilePlayer does not work if I passed an array of urls
[`#1612`](https://togithub.com/cookpete/react-player/pull/1612)
- fix: `src` sttribute become "undefinded" if `url` is an array
[`#1648`](https://togithub.com/cookpete/react-player/pull/1648)
- Adding keepPlaying to other player types
[`#1639`](https://togithub.com/cookpete/react-player/pull/1639)
-   CI [`#1654`](https://togithub.com/cookpete/react-player/pull/1654)
- Swap out broken youtube URL
[`#1659`](https://togithub.com/cookpete/react-player/pull/1659)
- Add keepPlaying to seekTo
[`#1620`](https://togithub.com/cookpete/react-player/pull/1620)
- Added forceDisableHls option for FilePlayer
[`#1625`](https://togithub.com/cookpete/react-player/pull/1625)
- added onPlaybackQualityChange prop
[`#1636`](https://togithub.com/cookpete/react-player/pull/1636)
- Update the list of supported YouTube domains
[`#1599`](https://togithub.com/cookpete/react-player/pull/1599)
- Fix
[#&#8203;1604](https://togithub.com/CookPete/react-player/issues/1604) -
FilePlayer does not work if I passed an array of urls
([#&#8203;1612](https://togithub.com/CookPete/react-player/issues/1612))
[`#1604`](https://togithub.com/cookpete/react-player/issues/1604)
- Support Wisita URLs with query params
[`#1591`](https://togithub.com/cookpete/react-player/issues/1591)
- Support vimeo manage links
[`#1593`](https://togithub.com/cookpete/react-player/issues/1593)
- Update readme
[`90237f5`](https://togithub.com/cookpete/react-player/commit/90237f51d43fc63870b0e6d0c86f4497f97ca586)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/redwoodjs/redwood).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuMzEuNSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
jtoar pushed a commit that referenced this issue Nov 2, 2023
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [react-player](https://togithub.com/CookPete/react-player) | [`2.12.0`
->
`2.13.0`](https://renovatebot.com/diffs/npm/react-player/2.12.0/2.13.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/react-player/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/react-player/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/react-player/2.12.0/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/react-player/2.12.0/2.13.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>CookPete/react-player (react-player)</summary>

###
[`v2.13.0`](https://togithub.com/CookPete/react-player/blob/HEAD/CHANGELOG.md#v2130)

[Compare
Source](https://togithub.com/CookPete/react-player/compare/v2.12.0...v2.13.0)

- Fix
[#&#8203;1604](https://togithub.com/CookPete/react-player/issues/1604) -
FilePlayer does not work if I passed an array of urls
[`#1612`](https://togithub.com/cookpete/react-player/pull/1612)
- fix: `src` sttribute become "undefinded" if `url` is an array
[`#1648`](https://togithub.com/cookpete/react-player/pull/1648)
- Adding keepPlaying to other player types
[`#1639`](https://togithub.com/cookpete/react-player/pull/1639)
-   CI [`#1654`](https://togithub.com/cookpete/react-player/pull/1654)
- Swap out broken youtube URL
[`#1659`](https://togithub.com/cookpete/react-player/pull/1659)
- Add keepPlaying to seekTo
[`#1620`](https://togithub.com/cookpete/react-player/pull/1620)
- Added forceDisableHls option for FilePlayer
[`#1625`](https://togithub.com/cookpete/react-player/pull/1625)
- added onPlaybackQualityChange prop
[`#1636`](https://togithub.com/cookpete/react-player/pull/1636)
- Update the list of supported YouTube domains
[`#1599`](https://togithub.com/cookpete/react-player/pull/1599)
- Fix
[#&#8203;1604](https://togithub.com/CookPete/react-player/issues/1604) -
FilePlayer does not work if I passed an array of urls
([#&#8203;1612](https://togithub.com/CookPete/react-player/issues/1612))
[`#1604`](https://togithub.com/cookpete/react-player/issues/1604)
- Support Wisita URLs with query params
[`#1591`](https://togithub.com/cookpete/react-player/issues/1591)
- Support vimeo manage links
[`#1593`](https://togithub.com/cookpete/react-player/issues/1593)
- Update readme
[`90237f5`](https://togithub.com/cookpete/react-player/commit/90237f51d43fc63870b0e6d0c86f4497f97ca586)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/redwoodjs/redwood).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4zMS41IiwidXBkYXRlZEluVmVyIjoiMzcuMzEuNSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/confirmed We have confirmed this is a bug topic/api
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants