Created
September 26, 2018 22:13
-
-
Save shrirambalakrishnan/9436a74f0778219a8568d985b0922d50 to your computer and use it in GitHub Desktop.
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
class Resolvers::CreateMovie < GraphQL::Function | |
# arguments passed as "args" | |
argument :name, !types.String | |
argument :year, types.String | |
argument :genre, types.String | |
# return type from the mutation | |
type Types::MovieType | |
# the mutation method | |
def call(_obj, args, _ctx) | |
movie_params = { name: args[:name], year: args[:year], genre: args[:genre] } | |
Movie.create!(movie_params) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment