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

Feature request: Add ability to specify custom headers #148

Closed
eugenehp opened this issue Jun 20, 2016 · 10 comments
Closed

Feature request: Add ability to specify custom headers #148

eugenehp opened this issue Jun 20, 2016 · 10 comments

Comments

@eugenehp
Copy link

It would be great to have functionality to add custom headers for authorisation purposes within GraphQL.

@eugenehp
Copy link
Author

I'm working on the PR at the moment.

screen shot 2016-06-22 at 20 03 38

@asiandrummer
Copy link
Contributor

Hi @eugenehp - thanks for the suggestion! We have discussed a custom header feature request in the past: #114 for one of the examples. Would it be more plausible for your use case to define a custom graphQLFetcher that deals with custom headers?

@eugenehp
Copy link
Author

Hi @asiandrummer yes, absolutely. I'll take a look into it. I already played with the example directory and got it working. What would be the best way to define custom graphQLFetcher to work with the HTTP headers?

screen shot 2016-06-22 at 20 31 25
screen shot 2016-06-22 at 20 31 27

@asiandrummer
Copy link
Contributor

I think you may have already looked at it, but refer to this example from the example code we have. It defines a custom graphQLFetcher with a set of custom headers.

The main reason why we'd prefer this is because we want GraphiQL to be independent of the network configurations. See #96 and #59 for more conversations about this please.

@eugenehp
Copy link
Author

@asiandrummer Thanks Hyo. I'm moving this here so we can have a way to place GraphiQL and custom versions of it as middleware.

@webmobiles
Copy link

how i can use the middleware to input the headers ? I've tried plugins for chrome and app for mac, and none of them is working ? it's a pity no input headers in the original graphiql, looks dogmatic decision

@asiandrummer
Copy link
Contributor

@webmobiles it's difficult to answer your question without knowing which middleware you're talking about and the plugins you've tried/without mentioning them. I heard that GraphiQL for Mac already supports a custom header, but have not seen it/used it myself.

I think Lee's comment here, in addition to multiple responses we've given to explain this, best describes why we wouldn't support custom headers in GraphiQL.

@balthild
Copy link

In many cases, we're using GraphiQL for debugging an API server in development. I think it's required that adding a field to the interface rather than change the behaviour programmatically.

  1. The GraphiQL is often bundled with the library, for example, Graphene and Apollo Server. We're not able to use a custom fetcher while using such these libraries.
  2. For debugging, we often need changing the header frequently than keep a static value. Setting headers on the interface will be much more convenient even if we could customize the fetcher.

@imolorhe
Copy link
Contributor

imolorhe commented Feb 3, 2018

@balthild You can checkout https://github.com/imolorhe/altair as well.

@balthild
Copy link

balthild commented Feb 4, 2018

@imolorhe Great project!

acao pushed a commit to acao/graphiql that referenced this issue Jun 1, 2019
…transform-es2015-duplicate-keys-6.24.1

Update babel-plugin-transform-es2015-duplicate-keys to the latest version 🚀
acao pushed a commit to acao/graphiql that referenced this issue Jun 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants