Adding rules to a type and its fields
See original GitHub issueQuestion about GraphQL Shield
Let’s say I have a type User
in my GraphQL schema, and I want to limit all queries on that type to those that match some isAuthenticated
rule. But within this User
type, I also have a secret
field, which I want to further restrict with an additional isAdministrator
rule. Is there any way to list both type-wide and field-specific rules if the two overlap, or would I need to enumerate all of the fields in User
to explicitly add the isAuthenticated
rule for each?
- I have checked other questions and found none that matches mine.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9
Top Results From Across the Web
Adding rules to a type and its fields · Issue #243 - GitHub
Let's say I have a type User in my GraphQL schema, and I want to limit all queries on that type to those...
Read more >Adding rules to relationship fields - IBM
In the property panel of a relationship fields, click Add Rule ; Select a Rule Type ; In Controlled By ; If you...
Read more >Add rules for performing other actions - Microsoft Support
Use the Add Rule button · Click Field Add rules for performing other actions next to the Field box. · Click the field...
Read more >Different types of custom field rules - Funnel Knowledge Base
There are three types of rules that you will come in contact with when creating or editing a custom field, namely: platform-specific rules....
Read more >Using the Rule Builder - Creating Forms - Wufoo Help
Types of Rules; Conditions & Actions; Adding & Deleting Rules ... Building rules is as easy as creating logical sentences based on the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It is easily achieved by defining custom
fallbackRule
.In following example, deny queries and mutations which have no rules but allow types and fields. So once you have rule that allows Query or Mutation you don’t have to add rule for returned type and (or) it’s fields.
You can play further with fallback for your needs.
@LK let’s think of the options we have. I think I understand why such functionality could be beneficial, however, I am struggling to find the right approach. My primary goal of this conversation is to understand the use case we are trying to solve and propose a meaningful solution to the problem which won’t pose a holdback in the future.
A few concerns that I have:
fallbacks
with permissions because it doesn’t scale on large systems.My proposal:
which would reduce to
A few open questions that I have:
fallbackRule
work?fallbackRule
altogether in favour ofextend
which could also acceptIRules
as an argument, or should we keep it narrowed down to types only?cc @ph55