X Tutup
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,3 @@ take the time to read it.
### License

Copyright (c) 2015, Andreas Marek and [Contributors](https://github.com/graphql-java/graphql-java/graphs/contributors)

### Supported by
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated, but tidying up an empty section

6 changes: 0 additions & 6 deletions README.zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,3 @@
### License

Copyright (c) 2015, Andreas Marek and [贡献者们](https://github.com/graphql-java/graphql-java/graphs/contributors)

### 帮助支持

![YourKit](https://www.yourkit.com/images/yklogo.png)

[YourKit](https://www.yourkit.com/) 通过 YourKit Java Profiler 能力对该项目提供了支持。
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The corresponding section was removed from the English version

2 changes: 1 addition & 1 deletion src/test/groovy/readme/DataFetchingExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void getProductsDataFetcher() {
DataFetcher productsDataFetcher = new DataFetcher<List<ProductDTO>>() {
@Override
public List<ProductDTO> get(DataFetchingEnvironment environment) {
DatabaseSecurityCtx ctx = environment.getContext();
DatabaseSecurityCtx ctx = environment.getGraphQlContext().get("databaseSecurityCtx");

List<ProductDTO> products;
String match = environment.getArgument("match");
Expand Down
7 changes: 3 additions & 4 deletions src/test/groovy/readme/DirectivesExamples.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class AuthorisationDirective implements SchemaDirectiveWiring {

@Override
public GraphQLFieldDefinition onField(SchemaDirectiveWiringEnvironment<GraphQLFieldDefinition> environment) {
String targetAuthRole = (String) environment.getDirective().getArgument("role").getArgumentValue().getValue();
String targetAuthRole = (String) environment.getAppliedDirective().getArgument("role").getArgumentValue().getValue();

//
// build a data fetcher that first checks authorisation roles before then calling the original data fetcher
Expand All @@ -48,8 +48,7 @@ public GraphQLFieldDefinition onField(SchemaDirectiveWiringEnvironment<GraphQLFi
DataFetcher authDataFetcher = new DataFetcher() {
@Override
public Object get(DataFetchingEnvironment dataFetchingEnvironment) throws Exception {
Map<String, Object> contextMap = dataFetchingEnvironment.getContext();
AuthorisationCtx authContext = (AuthorisationCtx) contextMap.get("authContext");
AuthorisationCtx authContext = dataFetchingEnvironment.getGraphQlContext().get("authContext");

if (authContext.hasRole(targetAuthRole)) {
return originalDataFetcher.get(dataFetchingEnvironment);
Expand Down Expand Up @@ -83,7 +82,7 @@ void contextWiring() {

ExecutionInput executionInput = ExecutionInput.newExecutionInput()
.query(query)
.graphQLContext(builder -> builder.put("authCtx", authCtx))
.graphQLContext(builder -> builder.put("authContext", authCtx))
.build();
}

Expand Down
X Tutup