-
-
Save ShopifyEng/f79ebe8ef43eb896cf795bc2cc9a68bc to your computer and use it in GitHub Desktop.
21- Understanding GraphQL for Beginners–Part Three - Completed solution for Try It Yourself #2
This file contains 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
module Mutations | |
class NutritionUpdate < BaseMutation | |
argument :id, ID, required: true | |
argument :food_id, ID, required: false | |
argument :serving_size, String, required: false | |
argument :calories, String, required: false | |
argument :total_fat, String, required: false | |
argument :trans_fat, String, required: false | |
argument :saturated_fat, String, required: false | |
argument :cholesterol, String, required: false | |
argument :sodium, String, required: false | |
argument :potassium, String, required: false | |
argument :total_carbohydrate, String, required: false | |
argument :dietary_fiber, String, required: false | |
argument :sugars, String, required: false | |
argument :protein, String, required: false | |
argument :vitamin_a, String, required: false | |
argument :vitamin_c, String, required: false | |
argument :calcium, String, required: false | |
argument :iron, String, required: false | |
type Types::NutritionType | |
def resolve(**args) | |
nutrition = Nutrition.find(args[:id]) | |
nutrition.update!(args) | |
return nutrition | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment