begin¶ ↑
This class was generated by the scaffold generator. It contains methods to get, list, create, update and delete instances of %{class_name}. Default routes are created for each of this method (use 'surikat list routes' or look inside config/routes.yml to see them). Example queries/mutations can be found in the comments for each method.
- Generated at
-
%{time}
end¶ ↑
class %{class_name}Queries < Surikat::BaseQueries
begin¶ ↑
Description: Retrieve one %{class_name} instance by its id Query Name: %{class_name}
Input: { 'id' => ID }
Output Type: %{class_name}
Query Example: %{examples_get}
end¶ ↑
def get %{class_name}.where(id: arguments['id']) end
begin¶ ↑
Description: Retrieve all %{class_name} instances Query Name: %{class_name_plural}
Input: { 'q' => String } A Ransack selector (github.com/activerecord-hackery/ransack)
Output Type: [%{class_name}]
Query Example: %{examples_list}
end¶ ↑
def all return %{class_name}.all unless arguments['q'] ransack = {} CGI::parse(arguments['q']).each { |k, v| ransack[k] = v.first} %{class_name}.ransack(ransack).result end
begin¶ ↑
Description: Create an instance of %{class_name} and return it; this is a mutation. Mutation Name: %{class_name}
Input: { '%{class_name}' => { %{input_type_detailed_no_id}
}
}
Output Type: %{class_name}
Query Example: %{examples_create}
Example Variables: %{pretty_create_vars}
end¶ ↑
def create %{class_name}.create arguments['%{class_name_downcase}'] end
begin¶ ↑
Description: Update an instance of %{class_name}; this is a mutation. Query Name: Update%{class_name}
Input: { '%{class_name}' => { %{input_type_detailed}
}
}
Output Type: Boolean
Query Example: %{examples_update}
Example Variables: %{pretty_update_vars}
end¶ ↑
def update %{class_name}.find(arguments['%{class_name_downcase}']['id']).update(arguments['%{class_name_downcase}'].without('id')) end
begin¶ ↑
Description: Delete an instance of %{class_name}. Query Name: Delete%{class_name}
Input: { 'id' => ID }
OutputType: Boolean
Query Example: %{examples_delete}
Example Variables: %{pretty_random_id}
end¶ ↑
def delete %{class_name}.where(id: arguments['id']).destroy_all true end
end