ian / rel

Rel is a Graph Database BaaS, built on Redis.
MIT License
13 stars 2 forks source link

@stateMachine annotation #22

Open ian opened 2 years ago

ian commented 2 years ago

@thelinuxlich found a cool SM library that would be really easy to integrate as a Rel extension:

https://github.com/StoneCypher/jssm

What if we expose this as a directive. Consider:

type Post {
  state: String! @stateMachine('draft -> published -> archived')
}

This would produce:

type Post {
  id: ID!
  state: String!
}

type Mutation {
  nextStateMachineForPost(id: ID!): Post
  prevStateMachineForPost(id: ID!): Post
  setStateMachineForPost(id: ID!): Post
}
thelinuxlich commented 2 years ago

So we would allow only one FSM per type?

ian commented 2 years ago

One FSM per field no? I guess we could name the mutations related to the field they represent.

thelinuxlich commented 2 years ago

There is also the definition of actions per transition:

Off 'TurnOn' -> Red;

ian commented 2 years ago

We should try and hit the 80% mark. Anything super custom a dev can do manually.

StoneCypher commented 2 years ago

Wow, it's neat seeing my library referenced

Let me know if I can help

I find that using the live editor really helps me get my head around what I want to build