ent icon indicating copy to clipboard operation
ent copied to clipboard

shared action and graphql mutation for pattern

Open lolopinto opened this issue 3 years ago • 1 comments

if you have a pattern that's used in multiple ents that has shared privacy, it's annoying to have to write that policy everywhere.

maybe this is configurable?

e.g.

import { Pattern, Field, Edge, ActionOperation } from '@snowtop/ent/schema';

export class EditorPattern implements Pattern {
  name = 'editor';

  fields: Field[] = [];

  edges: Edge[] = [
    {
      name: 'editors',
      edgeConstName: 'ObjectToEditor',
      schemaName: 'User',
      inverseEdge: {
        name: 'EditorToObject',
      },
      edgeActions: [
        {
          operation: ActionOperation.AddEdge,
        },
        {
          operation: ActionOperation.RemoveEdge,
        },
      ],
    },
  ];
}

and then you add this pattern in 3 ents, you need to copy the privacy policy in each action and on the client, you need to call 3 different mutations when needed.

it should be possible to indicate here that there's one action and mutation generated here and everyone uses that. that should probably be the default. and then if you want custom ones, to use something along the lines of https://github.com/lolopinto/ent/issues/521 to indicate that

may need some kind of marker interface that's generated so the API can check to make sure that the edges can be added/removed

lolopinto avatar Nov 02 '21 18:11 lolopinto

question that came wrt https://github.com/lolopinto/ent/pull/978

Quick question, assuming patterns will support triggers (do they already?), can there be a way to guarantee order of executions between triggers of a pattern and of an ent?

Patterns don't support triggers yet. Not sure how that'll work if/when they do. closest thing we have in terms of that is https://github.com/lolopinto/ent/issues/596. If they do, we can keep this in mind...

lolopinto avatar Jul 06 '22 19:07 lolopinto