Set context[:current_resource] upon login#193
Merged
mcelicalderon merged 1 commit intographql-devise:masterfrom Aug 2, 2021
Merged
Set context[:current_resource] upon login#193mcelicalderon merged 1 commit intographql-devise:masterfrom
mcelicalderon merged 1 commit intographql-devise:masterfrom
Conversation
If using [Object Authorization](https://graphql-ruby.org/authorization/authorization.html#object-authorization) that relies on `context[:current_resource]` it is not possible to query for data on the authenticatable object since `context[:current_user]` is `nil` after logging in since this is set at the controller level. This commit fixes this by setting `context[:current_resource]` to `resource` _if_ `context[:current_resource]` is `nil` (as the implementation may override this already). GitHub issue - graphql-devise#192
Contributor
Author
|
@mcelicalderon, how would you like this to be tested, or is this sufficient? Edit: test failures are confusing me a bit. Any idea what it may be? |
Member
|
Thank you, @TomasBarry! I can think of a way of testing that right now, but we can take care of that afterwards as existing tests didn't break. Apparently dta finally stopped supporting ruby 2.2 and that's why one of tests failed. As that's one of our main dependencies, we will drop support too. I'll fix that before merging your PR, so máster doesn't fail. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If using Object Authorization
that relies on
context[:current_resource]it is not possible to queryfor data on the authenticatable object since
context[:current_user]isnilafter logging in since this is set at the controller level.This commit fixes this by setting
context[:current_resource]toresourceifcontext[:current_resource]isnil(as theimplementation may override this already).
GitHub issue - #192