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

Question about request header configuration with initializer #82

Closed
mattduboismatt opened this issue Mar 31, 2020 · 1 comment
Closed

Comments

@mattduboismatt
Copy link

Hello! I've attempted to set a header with the initializer:

# config/initializers/graphiql.rb
GraphiQL::Rails.config.headers["Authorization"] = -> (_context) { "here" }

My graphql endpoint looks like this:

# app/controllers/application_controller.rb
# omitting the rest of the file...
  def graphql
    puts "*"*50
    puts request.headers["Authorization"]
    puts "*"*50
  end

Server log when sending the request via GraphiQL:

Started POST "/graphql" for ::1 at 2020-03-31 15:46:13 -0700
Processing by ApplicationController#graphql as */*
  Parameters: {"query"=>"", "variables"=>"null", "operationName"=>nil, "application"=>{"query"=>"", "variables"=>"null", "operationName"=>nil}}
**************************************************

**************************************************
No template found for ApplicationController#graphql, rendering head :no_content

Do I need to invoke the config? Something else? The header is nil. This is a new Rails app with the following versions:
Rails: 6.0.2.2
Ruby: 2.7.0
graphiql-rails: 1.7

@mattduboismatt mattduboismatt changed the title Quesiton about request header configuration with initializer Question about request header configuration with initializer Mar 31, 2020
@rmosolgo
Copy link
Owner

Hey, sorry you ran into trouble with this! I hope you found something that works for you. I just tried it out again on the latest graphiql-rails and rails and it seemed to work properly.

One thing to remember is that you have to restart your server if you modify initializers.

If anyone runs into this again, please open a new issue.

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

2 participants