File tree Expand file tree Collapse file tree 2 files changed +4
-6
lines changed
versioned_docs/version-v22 Expand file tree Collapse file tree 2 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,7 @@ class AuthorisationDirective implements SchemaDirectiveWiring {
84
84
DataFetcher authDataFetcher = new DataFetcher () {
85
85
@Override
86
86
public Object get (DataFetchingEnvironment dataFetchingEnvironment ) throws Exception {
87
- Map <String , Object> contextMap = dataFetchingEnvironment.getContext ();
88
- AuthorisationCtx authContext = (AuthorisationCtx ) contextMap .get ("authContext" );
87
+ AuthorisationCtx authContext = dataFetchingEnvironment .getGraphQlContext ().get ("authContext" );
89
88
90
89
if (authContext .hasRole (targetAuthRole )) {
91
90
return originalDataFetcher .get (dataFetchingEnvironment );
@@ -119,7 +118,7 @@ AuthorisationCtx authCtx = AuthorisationCtx.obtain();
119
118
120
119
ExecutionInput executionInput = ExecutionInput . newExecutionInput()
121
120
.query(query)
122
- .context( authCtx)
121
+ .graphQLContext(builder - > builder . put( " authContext " , authCtx) )
123
122
.build();
124
123
```
125
124
Original file line number Diff line number Diff line change @@ -84,8 +84,7 @@ class AuthorisationDirective implements SchemaDirectiveWiring {
84
84
DataFetcher authDataFetcher = new DataFetcher () {
85
85
@Override
86
86
public Object get (DataFetchingEnvironment dataFetchingEnvironment ) throws Exception {
87
- Map <String , Object> contextMap = dataFetchingEnvironment.getContext ();
88
- AuthorisationCtx authContext = (AuthorisationCtx ) contextMap .get ("authContext" );
87
+ AuthorisationCtx authContext = dataFetchingEnvironment .getGraphQlContext ().get ("authContext" );
89
88
90
89
if (authContext .hasRole (targetAuthRole )) {
91
90
return originalDataFetcher .get (dataFetchingEnvironment );
@@ -119,7 +118,7 @@ AuthorisationCtx authCtx = AuthorisationCtx.obtain();
119
118
120
119
ExecutionInput executionInput = ExecutionInput . newExecutionInput()
121
120
.query(query)
122
- .context( authCtx)
121
+ .graphQLContext(builder - > builder . put( " authContext " , authCtx) )
123
122
.build();
124
123
```
125
124
You can’t perform that action at this time.
0 commit comments