graphql / vscode-graphql

MIGRATED: VSCode GraphQL extension (autocompletion, go-to definition, syntax highlighting)
https://marketplace.visualstudio.com/items?itemName=Prisma.vscode-graphql
MIT License
555 stars 71 forks source link

Auth from outside .graphqlconfig #68

Closed covertbert closed 4 years ago

covertbert commented 6 years ago

Our .graphqlconfig references API tokens that are set in this manner "Authorization": "Bearer ${env:API_TOKEN}" with API_TOKEN being a token that changes regularly and is set via export API_TOKEN= in a shell.

Is there any way we can get this extension to authenticate properly so we can use the "execute query/mutation" features etc? Currently, of course, it will just say "API_TOKEN is not set"

divyenduz commented 6 years ago

Thanks for raising this issue. I will need to reproduce this. Do you have a small project maybe that I can use to reproduce this?

covertbert commented 6 years ago

Unfortunately I don't have a project that I'm able to share, however replicating this should be as simple as the following:

Apologies as I know this will still need quite a lot of set up on your part to replicate!

acao commented 4 years ago

@covertbert with the graphql-config@3.0.0 upgrade, you'll be able to use commonjs files, so you'll be able to do:

const { API_TOKEN } = process.env
module.exports = {
  projects: {
    myProject: {
      schema: "schema.graphql",
      extensions: {
        endpoints: {
          local: {
            url: "http://localhost:8000/app_dev.php/graphql",
            headers: {
              Authorization: `Bearer ${API_TOKEN}`
            }
          }
        }
      }
    }
  }
}
acao commented 4 years ago

prisma.vscode-graphql@0.3.1 released! please open new tickets if you have any issues