Skip to content

Move to trash, restore and delete permanently in Elixir

License

Notifications You must be signed in to change notification settings

iporaitech/recyclex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Recyclex

JUST OUTLINING SOME IDEAS YET

  1. Use string :id with type encoded (like Relay Global ID), or
  2. Use tuple {:id, type}, where id is integer and type is string representing the record type

Install

{:recyclex, "~> 0.1.0"}

Ecto migrations

  1. Create migration CreateRecycleBin
  2. Migrate

Absinthe GraphQL Macros

require Recyclex.GraphQL

# Add a :recycle_bin connection field / and connection (?)
Recyclex.GraphQL.connection_field()
connection(node_type: :recycle_bin_item)

# Add mutations
Recyclex.GraphQL.move_to_trash_mutation()
Recyclex.GraphQL.restore_mutation()
Recyclex.GraphQL.delete_permanent_mutation()

# Add node object :recycle_bin_item
Recyclex.GraphQL.node_object()

# Add pattern to resolve :recycle_bin_item to node interface
%RecycleBin.Item{}, _ ->
  :recycle_bin_item

# node field resolve (?)

Backend functions

Move a record to trash

Recyclex.move_to_trash(record OR global_id (?))

This would need record changeset, e.g.:

person
|> Person.delete_changeset()
|> delete_and_insert_into_bin(global_id)

Restore a record from trash

Recyclex.restore_from_trash(global_id OR {id, type})

View a record in the trash

# TODO: How to use maps instead of deriving Jason.Encoder protocol for each Ecto schema
get(global_id)

Delete record permanently

Recyclex.delete_permanent(record or global_id, or {id, type})

Do we need Dataloader functions?

data()
query(queryalble)

About

Move to trash, restore and delete permanently in Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published