diff --git a/lib/graphql_devise/types/credential_type.rb b/lib/graphql_devise/types/credential_type.rb index 79f6016c..0ba3142b 100644 --- a/lib/graphql_devise/types/credential_type.rb +++ b/lib/graphql_devise/types/credential_type.rb @@ -3,11 +3,12 @@ module GraphqlDevise module Types class CredentialType < BaseType - field :access_token, String, null: false - field :uid, String, null: false - field :token_type, String, null: false - field :client, String, null: false - field :expiry, Int, null: false + field :access_token, String, null: false + field :uid, String, null: false + field :token_type, String, null: false + field :client, String, null: false + field :expiry, Int, null: false + field :authorization, String, null: false def access_token object[DeviseTokenAuth.headers_names[:"access-token"]] @@ -28,6 +29,10 @@ def client def expiry object[DeviseTokenAuth.headers_names[:expiry]] end + + def authorization + object[DeviseTokenAuth.headers_names[:authorization]] + end end end end diff --git a/spec/requests/mutations/login_spec.rb b/spec/requests/mutations/login_spec.rb index 5bf04c1a..1f76015e 100644 --- a/spec/requests/mutations/login_spec.rb +++ b/spec/requests/mutations/login_spec.rb @@ -18,7 +18,7 @@ password: "#{password}" ) { user { email name signInCount } - credentials { accessToken uid tokenType client expiry } + credentials { accessToken uid tokenType client expiry authorization } } } GRAPHQL @@ -34,11 +34,12 @@ expect(json_response[:data][:userLogin]).to match( user: { email: user.email, name: user.name, signInCount: 1 }, credentials: { - accessToken: response.headers['access-token'], - uid: response.headers['uid'], - tokenType: response.headers['token-type'], - client: response.headers['client'], - expiry: response.headers['expiry'].to_i + accessToken: response.headers['access-token'], + uid: response.headers['uid'], + tokenType: response.headers['token-type'], + client: response.headers['client'], + expiry: response.headers['expiry'].to_i, + authorization: response.headers['Authorization'] } ) expect(json_response[:errors]).to be_nil