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

GraphQL client (default) is missing it's host. #321

Open
Saurou opened this issue Mar 24, 2023 · 8 comments
Open

GraphQL client (default) is missing it's host. #321

Saurou opened this issue Mar 24, 2023 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@Saurou
Copy link

Saurou commented Mar 24, 2023

Environment

Nuxt 3

Describe the bug

WARN GraphQL client (default) is missing it's host. is shown after running yarn on server.

It also has a typo, as it shoulod be its instead of it's.

Expected behaviour

host is added to nuxt.config.ts

export default defineNuxtConfig({
  'graphql-client': {
    clients: {
      default: {
        host: process.env.GQL_HOST,
        token: process.env.TOKEN,
        retainToken: true
      }
    }
  }
}

Reproduction

No response

Additional context

VS Code also marks host: as an error with the following description:

Type 'string | undefined' is not assignable to type 'string'.
  Type 'undefined' is not assignable to type 'string’.

Logs

No response

@Saurou Saurou added the bug Something isn't working label Mar 24, 2023
@Diizzayy Diizzayy self-assigned this Mar 24, 2023
@Diizzayy
Copy link
Owner

Diizzayy commented Mar 24, 2023

@Saurou The configuration you have above is correct and should in fact be working properly, have you ensured that the GQL_HOST environment variable is set?

VS Code also marks host: as an error with the following description:

Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string’.

the host property expects a string, the keys within process.env have a type of string | undefined, hence the type error.

Also, this module is configured to automatically detect the GQL_HOST variable, so you don't have to explicity set { host: process.env.GQL_HOST }

@Saurou Here is a quick demo I put together https://stackblitz.com/edit/nuxt-starter-k55tfm?file=app.vue
create file named .env in the project root and add the following:

GQL_HOST="https://spacex-api-2gl6xp7kua-ue.a.run.app/query"

@Saurou
Copy link
Author

Saurou commented Mar 29, 2023

@Diizzayy thanks.

It looks like the .env was deleted on the server, for some reason, hence why the error. That's also why I was not getting the warning locally.

I removed host from nuxt.config.ts settings, thanks for the suggestion. VS Code does however still mark both host and token with that error message, even if they both are declared on my local .env.

@bastianhilton
Copy link

I'm having the same issue even though my .env has the GQL_HOST='http:https://example.com' declared and no host in the GQL plugin.

@ajaxbo360
Copy link

ajaxbo360 commented Nov 23, 2023

@Saurou yup i also get the same error when deploying in my server ,however in my local its working fine without the host .env on production like was deleted wierd, did you manage to fix the error on deployment

@ajaxbo360
Copy link

@Diizzayy hope you doing. great i just wanna mention that this bug still not be fixed especially when deploying to server i get the error above the host is missing , i did the approch you give and yes it works on local environment but in production no you can’t use process.env.GQL_HOST ,HOPE YOU GUYS CAN FIX THIS ASAP

@Diizzayy
Copy link
Owner

@ajaxbo360 Thanks for resurfacing this issue. I'll be sure to investigate this today

@ajaxbo360
Copy link

ajaxbo360 commented Nov 23, 2023

Screen Shot 2023-11-23 at 15 09 28 @Diizzayy thanks bro much appreciated ,basically the env variable is not been used in host ,cause i tried on local ,everything is working i commented host but in production still give me the same issue host is missing, hope you have a wonderful day

@Tom-El-Egant
Copy link

Tom-El-Egant commented Jan 12, 2024

Facing the same issue.
I discovered that the .env variable has to be set on build time - changing it on runtime does not have any effect.
Since we deploy our nuxt application together with graphQL application in different environments with different urls, we only know the GQL_HOST on runtime (same dockerfile for build, but on runtime different hosts).
Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants