Sha256: e3da02fb015fa5670cc763ac1317edcbd6adfe02d8a5a6cc5b2aa4b8d30a218d

Contents?: true

Size: 715 Bytes

Versions: 30

Compression:

Stored size: 715 Bytes

Contents

module Mutations
  class Update<%= @camelize_name %> <%= "<" %> BaseMutation
    include Guardian
    argument :id, ID, required: true
    <% for field in @update_mutation_lines %><%=field%>
    <% end %>

    type Types::<%= @camelize_name %>Type

    def resolve(**params)
      check_authentication!
      update_<%= @snake_case_name %>(params)
    end

   private

   def update_<%= @snake_case_name %>(params)
     <%= "#{@snake_case_name} = #{@camelize_name}.find(params[:id])" %>

     if <%=@snake_case_name%>.update(params)
        <%=@snake_case_name%>
      else
        raise GraphQL::ExecutionError, "Invalid input: #{<%=@snake_case_name%>.errors.full_messages.join(', ')}"
      end
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
graphql_helper_generator-0.1.0 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.31 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.30 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.29 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.28 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.27 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.26 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.25 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.24 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.23 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.22 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.21 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.20 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.18 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.17 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.16 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.15 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.14 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql_helper_generator-0.0.13 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb
graphql-generator-0.0.12 lib/graphql_helper_generator/graphql_model/templates/mutations/update_mutation_template.erb