Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

gemspec
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

begin
require 'bundler/setup'
rescue LoadError
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/graphql_devise/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
ApplicationController = if Rails::VERSION::MAJOR >= 5
Class.new(ActionController::API)
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/graphql_devise/concerns/set_user_by_token.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Concerns
SetUserByToken = DeviseTokenAuth::Concerns::SetUserByToken
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/graphql_devise/graphql_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_dependency 'graphql_devise/application_controller'

module GraphqlDevise
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/graphql_devise/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module ApplicationHelper
end
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/graphql_devise/mailer_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MailerHelper
def confirmation_query(resource_name:, token:, redirect_url:)
Expand Down
2 changes: 2 additions & 0 deletions app/models/graphql_devise/concerns/model.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'graphql_devise/model/with_email_updater'

module GraphqlDevise
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

GraphqlDevise::Engine.routes.draw do
# Required as Devise forces routes to reload on eager_load
unless GraphqlDevise.schema_loaded?
Expand Down
2 changes: 2 additions & 0 deletions lib/generators/graphql_devise/install_generator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class InstallGenerator < ::Rails::Generators::Base
source_root File.expand_path('templates', __dir__)
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'rails'
require 'graphql'
require 'devise_token_auth'
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/concerns/controller_methods.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Concerns
module ControllerMethods
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/default_operations/mutations.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'graphql_devise/mutations/base'
require 'graphql_devise/mutations/login'
require 'graphql_devise/mutations/logout'
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/default_operations/resolvers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'graphql_devise/resolvers/base'
require 'graphql_devise/resolvers/check_password_token'
require 'graphql_devise/resolvers/confirm_account'
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'graphql_devise/rails/routes'

module GraphqlDevise
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/errors/authentication_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class AuthenticationError < ExecutionError
def to_h
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/errors/detailed_user_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class DetailedUserError < ExecutionError
def initialize(message, errors:)
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/errors/error_codes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
ERROR_CODES = {
user_error: 'USER_ERROR',
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/errors/execution_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class ExecutionError < GraphQL::ExecutionError
end
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/errors/user_error.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class UserError < ExecutionError
def to_h
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/model/with_email_updater.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Model
class WithEmailUpdater
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mount_method/operation_preparer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'operation_preparers/gql_name_setter'
require_relative 'operation_preparers/mutation_field_setter'
require_relative 'operation_preparers/resolver_type_setter'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OperationPreparers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OperationPreparers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OperationPreparers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OperationPreparers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OperationPreparers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OperationPreparers
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mount_method/operation_sanitizer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
class OperationSanitizer
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mount_method/option_sanitizer.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'supported_options'

module GraphqlDevise
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OptionSanitizers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OptionSanitizers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OptionSanitizers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OptionSanitizers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'supported_operations_validator'

module GraphqlDevise
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OptionValidators
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module MountMethod
module OptionValidators
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mount_method/options_validator.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'option_validators/skip_only_validator'
require_relative 'option_validators/provided_operations_validator'

Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mount_method/supported_options.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require_relative 'option_sanitizers/array_checker'
require_relative 'option_sanitizers/hash_checker'
require_relative 'option_sanitizers/string_checker'
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mutations/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'devise_token_auth/version'

module GraphqlDevise
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mutations/login.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Mutations
class Login < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mutations/logout.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Mutations
class Logout < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mutations/resend_confirmation.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Mutations
class ResendConfirmation < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mutations/send_password_reset.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Mutations
class SendPasswordReset < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mutations/sign_up.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Mutations
class SignUp < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/mutations/update_password.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Mutations
class UpdatePassword < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/rails/routes.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module ActionDispatch::Routing
class Mapper
def mount_graphql_devise_for(resource, options = {})
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/resolvers/base.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'devise_token_auth/version'

module GraphqlDevise
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/resolvers/check_password_token.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Resolvers
class CheckPasswordToken < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/resolvers/confirm_account.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Resolvers
class ConfirmAccount < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/resolvers/dummy.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Resolvers
class Dummy < Base
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/resource_loader.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class ResourceLoader
def initialize(resource, options = {}, routing = false)
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class Schema < GraphQL::Schema
end
Expand Down
8 changes: 8 additions & 0 deletions lib/graphql_devise/schema_plugin.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
class SchemaPlugin
DEFAULT_NOT_AUTHENTICATED = ->(field) { raise GraphqlDevise::AuthenticationError, "#{field} field requires authentication" }
Expand All @@ -11,6 +13,7 @@ def initialize(query: nil, mutation: nil, authenticate_default: true, resource_l

# Must happen on initialize so operations are loaded before the types are added to the schema on GQL < 1.10
load_fields
reconfigure_warden!
end

def use(schema_definition)
Expand Down Expand Up @@ -92,6 +95,11 @@ def authenticate_option(field, trace_data)
end
end

def reconfigure_warden!
Devise.class_variable_set(:@@warden_configured, nil)
Devise.configure_warden!
end

def load_fields
@resource_loaders.each do |resource_loader|
raise Error, 'Invalid resource loader instance' unless resource_loader.instance_of?(GraphqlDevise::ResourceLoader)
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/types/authenticatable_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Types
class AuthenticatableType < GraphQL::Schema::Object
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/types/credential_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Types
class CredentialType < GraphQL::Schema::Object
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/types/mutation_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Types
class MutationType < GraphQL::Schema::Object
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/types/query_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
module Types
class QueryType < GraphQL::Schema::Object
Expand Down
2 changes: 2 additions & 0 deletions lib/graphql_devise/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module GraphqlDevise
VERSION = '0.12.3'.freeze
end
2 changes: 2 additions & 0 deletions spec/dummy/Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.

Expand Down
4 changes: 3 additions & 1 deletion spec/dummy/app/controllers/api/v1/graphql_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module Api
module V1
class GraphqlController < ApplicationController
Expand All @@ -23,7 +25,7 @@ def execute_params(item)
{
operation_name: item[:operationName],
variables: ensure_hash(item[:variables]),
context: graphql_context(:user)
context: graphql_context([:user, :schema_user])
}
end

Expand Down
Loading