diff --git a/.circleci/config.yml b/.circleci/config.yml index 4bb82a90..6e5077d1 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,13 +20,13 @@ jobs: - checkout - restore_cache: keys: - - v2.0-<< parameters.gemfile >>-<< parameters.ruby-version >> + - v2.3-<< parameters.gemfile >>-<< parameters.ruby-version >> - run: gem install bundler -v '1.17' - run: name: Install dependencies command: bundle install - save_cache: - key: v2.0-<< parameters.gemfile >>-<< parameters.ruby-version >> + key: v2.3-<< parameters.gemfile >>-<< parameters.ruby-version >> paths: - vendor/bundle - run: diff --git a/.rubocop.yml b/.rubocop.yml index ad421f1c..17688bb6 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,7 +4,7 @@ require: - rubocop-rails AllCops: - TargetRubyVersion: 2.3 + TargetRubyVersion: 2.4.4 DisplayCopNames: true Exclude: - bin/**/* diff --git a/CHANGELOG.md b/CHANGELOG.md index 2336951d..19f74e2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## [v1.2.0](https://github.com/graphql-devise/graphql_devise/tree/v1.2.0) (2022-11-14) + +[Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v1.1.1...v1.2.0) + +**Implemented enhancements:** + +- Set base controller from route mount [\#237](https://github.com/graphql-devise/graphql_devise/pull/237) ([00dav00](https://github.com/00dav00)) + ## [v1.1.1](https://github.com/graphql-devise/graphql_devise/tree/v1.1.1) (2022-10-20) [Full Changelog](https://github.com/graphql-devise/graphql_devise/compare/v1.1.0...v1.1.1) diff --git a/README.md b/README.md index d7afd20c..4faeef3b 100644 --- a/README.md +++ b/README.md @@ -157,7 +157,8 @@ Rails.application.routes.draw do login: Mutations::Login }, skip: [:register], - # base_controller: ApiController, + # optional, use only if you need a specific base controller to mount the new actions + base_controller: ApiController, additional_mutations: { # generates mutation { adminUserSignUp } admin_user_sign_up: Mutations::AdminUserSignUp @@ -265,7 +266,11 @@ our default classes and yielding your customized code after calling `super`, exa and an `authenticatable` type to every query. Gem will try to use `Types::Type` by default, so in our example you could define `Types::UserType` and every query and mutation will use it. But, you can override this type with this option like in the example. -1. `base_controller`: Specifying this is optional. By default the controller used to mount the route is `GraphqlDevise::ApplicationController` which inherits from `ActionController::API` or `ActionController::Base` depending on the rails version of the main project. This option allows you to set the controller used as the parent of the controller where the route will be mounted. This config is similar to `Devise`'s `base_controller` config but in this case each route can have a different parent controller. +1. `base_controller`: Specifying this is optional. By default the controller used to mount the route is +`GraphqlDevise::ApplicationController` which inherits from `ActionController::API` or `ActionController::Base` +depending on the rails version of the main project. This option allows you to set the controller used as the parent of +the controller where the route will be mounted. This config is similar to `Devise`'s `base_controller` config but in +this case each route can have a different parent controller. **This option only works if you are using the mount method.** 1. `skip`: An array of the operations that should not be available in the authentication schema. All these operations are symbols and should belong to the list of available operations in the gem. 1. `only`: An array of the operations that should be available in the authentication schema. The `skip` and `only` options are diff --git a/lib/graphql_devise/version.rb b/lib/graphql_devise/version.rb index f5880d3b..c94d98b4 100644 --- a/lib/graphql_devise/version.rb +++ b/lib/graphql_devise/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module GraphqlDevise - VERSION = '1.1.1' + VERSION = '1.2.0' end diff --git a/spec/requests/mutations/login_spec.rb b/spec/requests/mutations/login_spec.rb index a323e86a..748ca34a 100644 --- a/spec/requests/mutations/login_spec.rb +++ b/spec/requests/mutations/login_spec.rb @@ -185,23 +185,22 @@ end end - if DeviseTokenAuth.respond_to?(:cookie_enabled) context 'when using cookies for auth' do let!(:user) { create(:user, :confirmed, password: password, email: 'vvega@wallaceinc.com') } let(:email) { user.email } let(:query) do <<-GRAPHQL - mutation { - userLogin( - email: "#{email}", - password: "#{password}" - ) { - authenticatable { email } - credentials { accessToken uid tokenType client expiry } + mutation { + userLogin( + email: "#{email}", + password: "#{password}" + ) { + authenticatable { email } + credentials { accessToken uid tokenType client expiry } + } } - } - GRAPHQL + GRAPHQL end around do |example| @@ -214,7 +213,7 @@ it 'honors DTA configuration of setting auth info in cookies' do cookie = cookies.get_cookie('auth_cookie') - expect(JSON.parse(cookie.value).keys).to include(*%w[uid access-token client]) + expect(JSON.parse(cookie.value).keys).to include('uid', 'access-token', 'client') end end end