Sha256: dbe2fea209070f8e0573c8a3860efc0d7cff185a573650458b0d91fb9bbe08ce

Contents?: true

Size: 887 Bytes

Versions: 120

Compression:

Stored size: 887 Bytes

Contents

# frozen_string_literal: true

<% module_namespacing_when_supported do -%>
module Mutations
  class <%= class_name %>Update < BaseMutation
    description "Updates a <%= file_name %> by id"

    field :<%= file_name %>, Types::<%= options[:namespaced_types] ? 'Objects::' : '' %><%= class_name %>Type, null: false

    argument :id, ID, required: true
    argument :<%= file_name %>_input, Types::<%= options[:namespaced_types] ? 'Inputs::' : '' %><%= class_name %>InputType, required: true

    def resolve(id:, <%= file_name %>_input:)
      <%= singular_table_name %> = ::<%= orm_class.find(class_name, "id") %>
      raise GraphQL::ExecutionError.new "Error updating <%= file_name %>", extensions: <%= singular_table_name %>.errors.to_hash unless <%= orm_instance.update("**#{file_name}_input") %>

      { <%= file_name %>: <%= singular_table_name %> }
    end
  end
end
<% end -%>

Version data entries

120 entries across 120 versions & 1 rubygems

Version Path
graphql-2.4.14 lib/generators/graphql/templates/mutation_update.erb
graphql-2.3.22 lib/generators/graphql/templates/mutation_update.erb
graphql-2.1.15 lib/generators/graphql/templates/mutation_update.erb
graphql-1.13.24 lib/generators/graphql/templates/mutation_update.erb
graphql-2.0.32 lib/generators/graphql/templates/mutation_update.erb
graphql-2.1.14 lib/generators/graphql/templates/mutation_update.erb
graphql-2.2.17 lib/generators/graphql/templates/mutation_update.erb
graphql-2.3.21 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.13 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.12 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.11 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.10 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.9 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.8 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.7 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.6 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.5 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.4 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.3 lib/generators/graphql/templates/mutation_update.erb
graphql-2.4.2 lib/generators/graphql/templates/mutation_update.erb