Skip to content

Add an Object to manage the schema context#36

Merged
AlessioRocco merged 4 commits intomasterfrom
schema-context
Nov 22, 2019
Merged

Add an Object to manage the schema context#36
AlessioRocco merged 4 commits intomasterfrom
schema-context

Conversation

@AlessioRocco
Copy link
Copy Markdown
Contributor

@AlessioRocco AlessioRocco commented Nov 22, 2019

Extract the generation of the schema context into an own class (SolidusGraphqlApi::Context) and add the current_ability, current_store and order_token to the context.

@AlessioRocco AlessioRocco changed the title Add a service object to create the schema context Add an Object to manage the schema context Nov 22, 2019
@AlessioRocco AlessioRocco self-assigned this Nov 22, 2019
@AlessioRocco AlessioRocco force-pushed the schema-context branch 2 times, most recently from 2ec3b63 to d4556ea Compare November 22, 2019 13:44
@AlessioRocco AlessioRocco marked this pull request as ready for review November 22, 2019 13:46
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
@AlessioRocco AlessioRocco merged commit 5f7d16f into master Nov 22, 2019
@AlessioRocco AlessioRocco deleted the schema-context branch November 22, 2019 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants