Giter Site home page Giter Site logo

Comments (3)

aarona avatar aarona commented on June 27, 2024 1

You're right. I figured out how I got to this issue. I'm using the GraphiQL application to hit localhost:3000/graphql_auth and it was just hanging/spinning (which should be the issue you'd be concerned with) and figured that this was related. I do have an execute action though:

class GraphqlController < ApplicationController
  # If accessing from outside this domain, nullify the session
  # This allows for outside API access while preventing CSRF attacks,
  # but you'll have to authenticate your user separately
  protect_from_forgery with: :null_session

  def execute
    variables = ensure_hash(params[:variables])
    query = params[:query]
    operation_name = params[:operationName]
    context = {
      # Query context goes here, for example:
      # current_user: current_user,
    }
    result = JwtRailsExampleSchema.execute(query, variables: variables, context: context, operation_name: operation_name)
    render json: result
  rescue => e
    raise e unless Rails.env.development?
    handle_error_in_development e
  end
...
end

My graphql_auth route is working now for some reason so I'll have to figure out what else is going on with my project. Thanks!

from graphql_devise.

mcelicalderon avatar mcelicalderon commented on June 27, 2024

Hey @aarona looks like this might be unrelated to the gem. As you can see on your routes output, the gem uses the auth action on our own graphql_devise/graphql controller. How you mount your own graphql schema is a different story. For that, you should follow the graphql gem instructions and run the generator in your app. Looks like your own personal graphql controller is missing the action execute which should process que request using your own graphql schema. Look how the dummy app does it in the routes and controller

from graphql_devise.

aarona avatar aarona commented on June 27, 2024

Ok after some research it looks like its because I'm using the create-repack-app which creates an API only rails app. This line in execute:

protect_from_forgery with: :null_session

is causing the problem. Are you guys using API only rails apps when testing? I wonder what I should do about this? I think I can just delete that line if I use CORS and graphql_devise for authentication, right?

from graphql_devise.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.