Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: wildcard functionality for field names #1509

Open
darrellwarde opened this issue Feb 8, 2023 · 0 comments
Open

Feature request: wildcard functionality for field names #1509

darrellwarde opened this issue Feb 8, 2023 · 0 comments

Comments

@darrellwarde
Copy link

Feature request

Is your feature request related to a problem? Please describe

Say I have the following Mutation object:

type Mutation {
  createMovies: [Movie!]!
  updateMovies: [Movie!]!
  createActors: [Actor!]!
  updateActors: [Actor!]!
}

It doesn't appear to be possible to add a rule to any Mutation fields beginning "create".

Describe the solution you'd like

Additional wildcard functionality that allows you to use "*" in any string key.

Given the above type definitions, I would like to be able to do the following:

const isCreator = rule()(async (parent, args, ctx, info) => {
  return ctx.roles.includes("CREATOR");
});

const permissions = shield({
  Mutation: {
    "create*": isCreator,
  },
});

This would add a check for the role "CREATOR" when hitting either the createMovies or createActors Mutation.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant