Skip to content

Add saveInAddressBook mutation#83

Merged
AlessioRocco merged 6 commits intomasterfrom
save-in-address-book
Mar 13, 2020
Merged

Add saveInAddressBook mutation#83
AlessioRocco merged 6 commits intomasterfrom
save-in-address-book

Conversation

@AlessioRocco
Copy link
Copy Markdown
Contributor

@AlessioRocco AlessioRocco commented Mar 6, 2020

The mutation accepts an address and a boolean named default as inputs
and saves the address to the current user address book. If the default
argument is true, the address will be the default one used during the
checkout.

@AlessioRocco AlessioRocco self-assigned this Mar 6, 2020
@AlessioRocco AlessioRocco force-pushed the save-in-address-book branch 6 times, most recently from 58cd1db to e76d970 Compare March 6, 2020 14:15
@AlessioRocco AlessioRocco marked this pull request as ready for review March 6, 2020 14:16
@AlessioRocco AlessioRocco force-pushed the save-in-address-book branch 4 times, most recently from b3766a3 to aceba5e Compare March 13, 2020 09:49
@AlessioRocco AlessioRocco linked an issue Mar 13, 2020 that may be closed by this pull request
3 tasks
@AlessioRocco AlessioRocco added this to the User Management milestone Mar 13, 2020
@AlessioRocco AlessioRocco added the enhancement New feature or request label Mar 13, 2020
@AlessioRocco AlessioRocco force-pushed the save-in-address-book branch 4 times, most recently from 2993217 to 9a811f5 Compare March 13, 2020 14:34
Copy link
Copy Markdown
Contributor

@ChristianRimondi ChristianRimondi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

This type is used to presents errors as data as suggested in the
graphql-ruby documentation:

https://graphql-ruby.org/mutations/mutation_errors.html#errors-as-data
This input object is used for every mutation that needs an address as input.
To notice that for the country_id and state_id arguments the auto loading
was used:

https://graphql-ruby.org/mutations/mutation_classes.html#auto-loading-arguments
This raises a graphql-friendly error with the message from the
CanCan::AccessDenied exception message.
The added helper method are:

  - current_user
  - current_ability
  - user_errors

The 'current_user' and 'current_ability' delegates to the
context, 'user_errors' is used to return 'errors as data' as
described in the documentation:

https://graphql-ruby.org/mutations/mutation_errors.html#errors-as-data
The mutation accepts an address and a boolean named default as inputs
and saves the address to the current user address book. If the default
argument is true, the address will be the default one used during the
checkout.
Using command "bundle exec rake schema:idl"
@AlessioRocco AlessioRocco force-pushed the save-in-address-book branch from a32ef01 to 885ff42 Compare March 13, 2020 15:09
@AlessioRocco AlessioRocco merged commit bb6e2c7 into master Mar 13, 2020
@rainerdema rainerdema deleted the save-in-address-book branch March 13, 2020 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AddressBook Mutations

2 participants