You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -123,6 +122,98 @@ type Post @authorization(validate: [
123
122
In case there is no `operations` argument with a list of operations, the GraphQL Library treats the authorization configuration as if the full list of operations had been provided.
124
123
====
125
124
125
+
=== When
126
+
127
+
Validation can be configured to only be performed before or after an operation is executed.
128
+
This is done using the `when` argument which accepts an array of the following values:
129
+
130
+
* `BEFORE`
131
+
* `AFTER`
132
+
133
+
Additionally, some operations only support validation either before or after them, which is summarised in this table:
134
+
135
+
[cols="2,5"]
136
+
|===
137
+
| `operation` | `when`
138
+
139
+
| `READ`
140
+
| `BEFORE`
141
+
142
+
| `AGGREGATE`
143
+
| `BEFORE`
144
+
145
+
| `CREATE`
146
+
| `AFTER`
147
+
148
+
| `UPDATE`
149
+
| `BEFORE`, `AFTER`
150
+
151
+
| `DELETE`
152
+
| `BEFORE`
153
+
154
+
| `CREATE_RELATIONSHIP`
155
+
| `BEFORE`, `AFTER`
156
+
157
+
| `DELETE_RELATIONSHIP`
158
+
| `BEFORE`, `AFTER`
159
+
160
+
|===
161
+
162
+
As an example, let's say you want someone to be able to update a post.
163
+
If you want to check that after the update the author of the post is still the current user, do the following:
The `@authorization` directive can be used either on object types or their fields, with the former being used in examples for the most part on this page.
179
+
When applied to a field, the authorization rules are only evaluated if the matching operations are performed on that field.
180
+
For example, consider a `User` type with a `password` field:
In each ruleset (`filter` and `validate`), rules are joined with an `OR`.
245
+
The two rulesets are joined with an `AND`.
246
+
247
+
For example, the following would allow for the update of a `User` node if the JWT roles claim includes `admin` _or_ if the `locked` property on the node is `false`:
If you want to combine the rule that a user must be an admin with the rule that the `locked` property must be `false` in order to update a `User` node, add them both to the `where` field using `AND` in a single rule:
Copy file name to clipboardExpand all lines: modules/ROOT/pages/security/subscriptions-authorization.adoc
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,8 @@
3
3
= Subscriptions authorization
4
4
5
5
Subscriptions require their own authorization rules, which are configured with the `@subscriptionsAuthorization` directive.
6
-
These rules are different to authorization rules for queries and mutations because they use filtering rules available for subscriptions events.
6
+
These rules are different to authorization rules for queries and mutations because they use filtering rules available for subscriptions events.
7
+
These filtering rules can only be used to filter against the properties of the nodes impacted by the events.
7
8
8
9
All subscriptions authorization rules have an implied requirement for authentication, given that the rules are normally evaluated against values in the JWT payload.
Copy file name to clipboardExpand all lines: modules/ROOT/pages/types/relationships.adoc
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -65,6 +65,9 @@ You can add relationship properties to the example in two steps:
65
65
. Add a type definition decorated with the `@relationshipProperties` directive, containing the desired relationship properties.
66
66
. Add a `properties` argument to both "sides" (or just one side, if you prefer) of the `@relationship` directive which points to the newly defined interface.
67
67
68
+
Relationship properties fields can only be primitive types or their list variants.
69
+
You cannot map complex types such as object types into the types modelling relationship properties.
70
+
68
71
For example, suppose you want to distinguish which roles an actor played in a movie:
0 commit comments