Add an Object to manage the schema context#36
Merged
AlessioRocco merged 4 commits intomasterfrom Nov 22, 2019
Merged
Conversation
7e8f41b to
f6ca38d
Compare
2ec3b63 to
d4556ea
Compare
This commit moves the responsibility to create the schema context from the controller to the SolidusGraphqlApi::Context class. It accepts the request as an argument and implements the `#to_h` method that returns the context needed by SolidusGraphqlApi::Schema#execute. For now, includes only the current user but will be integrated with more context needed stuff. It also aligns the controller specs with the new implementation.
It uses "Spree::Ability" class to extract the abilities for the user that can be a logged-in one or a guest.
For allowing guests to manage their cart and place their order, you can use the order's guest token. This token is contained in the guest_token property of the order, and it allows you to perform certain checkout-related operations on the order such as managing line items, completing the checkout flow etc. The order token must be passed in the X-Spree-Order-Token header in the following form: X-Spree-Order-Token: ORDER_TOKEN
d4556ea to
b9e4ce4
Compare
ChristianRimondi
approved these changes
Nov 22, 2019
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.
Extract the generation of the schema context into an own class (
SolidusGraphqlApi::Context) and add thecurrent_ability,current_storeandorder_tokento the context.