-
-
Save ShopifyEng/63511608217c9927dc0749d48e131c91 to your computer and use it in GitHub Desktop.
20 - Understanding GraphQL for Beginners - Part 3 - Solution to nutritionCreate
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 NutritionCreate < BaseMutation | |
argument :food_id, ID, required: true | |
argument :serving_size, String, required: true | |
argument :calories, String, required: true | |
argument :total_fat, String, required: true | |
argument :trans_fat, String, required: true | |
argument :saturated_fat, String, required: true | |
argument :cholesterol, String, required: true | |
argument :sodium, String, required: true | |
argument :potassium, String, required: true | |
argument :total_carbohydrate, String, required: true | |
argument :dietary_fiber, String, required: true | |
argument :sugars, String, required: true | |
argument :protein, String, required: true | |
argument :vitamin_a, String, required: true | |
argument :vitamin_c, String, required: true | |
argument :calcium, String, required: true | |
argument :iron, String, required: true | |
type Types::NutritionType | |
def resolve(**args) | |
Nutrition.create!(**args) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment