Sha256: 1a9e59c2c6a6e8fb9ac452402702c925e0c501879340966ac890d06eb7441f0b

Contents?: true

Size: 836 Bytes

Versions: 108

Compression:

Stored size: 836 Bytes

Contents

# frozen_string_literal: true

<% module_namespacing_when_supported do -%>
module Mutations
  class <%= class_name %>Create < BaseMutation
    description "Creates a new <%= file_name %>"

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

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

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

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

Version data entries

108 entries across 108 versions & 1 rubygems

Version Path
graphql-2.1.4 lib/generators/graphql/templates/mutation_create.erb
graphql-1.13.20 lib/generators/graphql/templates/mutation_create.erb
graphql-2.1.3 lib/generators/graphql/templates/mutation_create.erb
graphql-2.1.2 lib/generators/graphql/templates/mutation_create.erb
graphql-2.1.1 lib/generators/graphql/templates/mutation_create.erb
graphql-2.1.0 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.27 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.26 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.25 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.24 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.23 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.22 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.21 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.20 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.17.2 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.17.1 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.19 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.18 lib/generators/graphql/templates/mutation_create.erb
graphql-2.0.17 lib/generators/graphql/templates/mutation_create.erb
graphql-1.13.19 lib/generators/graphql/templates/mutation_create.erb