Applying a rule to all crud operations


In some types of the schema I designed, I want the same rule to be applied to all CRUD operations.
Is it possible to that without copy-paste for each operation?


1 Like

@michaelcompton I don’t know why I have such a hard time finding your repo where you break out the rules from the schema. Can you share that here again.


This is the repo

There’s a schema.graphl file that’s the actual schema, then all the rules are in separate files and get added by deploy.js in a deployment step.

1 Like

That looks great! Do you think this can be a feature of slash where I supply the scheme and a bunch of rule files and you apply them to the scheme on deploy?

Probably a question better directed to @gja

I’m actually about to submit a PR for the command line tool slash-graphql - npm I’ll ping back when we have something sorted out.

1 Like

@michaelcompton while I’d probably accept this, Is string interpolation the way to go here? If so, we should at least pick up mustache or something so we can do smarter things.

That said, string interpolation seems inelegant. Wouldn’t it make sense to be able to define these things as a fragment or a query so that it can be referred to in each block, but defined once?

The power of graphql and graphql schema is that they are simple to write and understand.