class Artemis::MutationGenerator

Public Instance Methods

generate_mutation_file() click to toggle source
# File lib/generators/artemis/mutation/mutation_generator.rb, line 13
def generate_mutation_file
  template "mutation.graphql", graphql_file_path
end

Private Instance Methods

arguments() click to toggle source
# File lib/generators/artemis/mutation/mutation_generator.rb, line 27
def arguments
  target_mutation.arguments
end
graphql_file_path() click to toggle source
# File lib/generators/artemis/mutation/mutation_generator.rb, line 23
def graphql_file_path
  "app/operations/#{service_name.underscore}/#{graphql_file_name.presence || mutation_name}.graphql"
end
mutation_name() click to toggle source
# File lib/generators/artemis/mutation/mutation_generator.rb, line 19
def mutation_name
  mutation_type.underscore
end
schema() click to toggle source
# File lib/generators/artemis/mutation/mutation_generator.rb, line 36
def schema
  service_name.camelize.constantize.endpoint.schema
end
service_name() click to toggle source
# File lib/generators/artemis/mutation/mutation_generator.rb, line 40
def service_name
  options['service'].presence || begin
    services = Artemis::GraphQLEndpoint.registered_services

    if services.size == 1
      services.first
    else
      fail "Please specify a service name (available services: #{services.join(", ")}):\n\n" \
           "  rails g artemis:mutation #{mutation_type} #{graphql_file_name} --service SERVICE"
    end
  end
end
target_mutation() click to toggle source
# File lib/generators/artemis/mutation/mutation_generator.rb, line 31
def target_mutation
  schema.find("Mutation").fields[mutation_type] ||
    raise(GraphQL::Schema::Finder::MemberNotFoundError, "Could not find type `#{mutation_type}` in schema.")
end