Skip to content

Instantly share code, notes, and snippets.

@shrirambalakrishnan
Created September 26, 2018 22:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shrirambalakrishnan/9436a74f0778219a8568d985b0922d50 to your computer and use it in GitHub Desktop.
Save shrirambalakrishnan/9436a74f0778219a8568d985b0922d50 to your computer and use it in GitHub Desktop.
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