File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
main/java/org/springframework/graphql/execution
test/java/org/springframework/graphql/execution Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 20
20
21
21
import graphql .ExecutionInput ;
22
22
import graphql .GraphQLContext ;
23
+ import graphql .TrivialDataFetcher ;
23
24
import graphql .schema .DataFetcher ;
24
25
import graphql .schema .DataFetchingEnvironment ;
25
26
import graphql .schema .FieldCoordinates ;
@@ -150,6 +151,9 @@ public TraversalControl visitGraphQLFieldDefinition(
150
151
}
151
152
152
153
private boolean applyDecorator (DataFetcher <?> dataFetcher ) {
154
+ if (dataFetcher instanceof TrivialDataFetcher ) {
155
+ return false ;
156
+ }
153
157
Class <?> type = dataFetcher .getClass ();
154
158
String packageName = type .getPackage ().getName ();
155
159
if (packageName .startsWith ("graphql." )) {
Original file line number Diff line number Diff line change 27
27
import graphql .GraphQL ;
28
28
import graphql .GraphQLError ;
29
29
import graphql .GraphqlErrorBuilder ;
30
+ import graphql .TrivialDataFetcher ;
30
31
import graphql .schema .DataFetcher ;
31
32
import graphql .schema .DataFetcherFactories ;
33
+ import graphql .schema .FieldCoordinates ;
32
34
import graphql .schema .GraphQLFieldDefinition ;
35
+ import graphql .schema .GraphQLSchema ;
33
36
import graphql .schema .idl .SchemaDirectiveWiring ;
34
37
import graphql .schema .idl .SchemaDirectiveWiringEnvironment ;
35
38
import io .micrometer .context .ContextRegistry ;
@@ -238,4 +241,18 @@ else if (value instanceof Mono) {
238
241
tester .accept (directiveWiring , env -> Mono .just ("hello" ));
239
242
}
240
243
244
+ @ Test //gh-980
245
+ void trivialDataFetcherIsNotDecorated () {
246
+ GraphQL graphQl = GraphQlSetup .schemaContent (SCHEMA_CONTENT )
247
+ .queryFetcher ("greeting" , (TrivialDataFetcher ) env -> "hello" )
248
+ .toGraphQl ();
249
+
250
+ GraphQLSchema schema = graphQl .getGraphQLSchema ();
251
+ FieldCoordinates coordinates = FieldCoordinates .coordinates ("Query" , "greeting" );
252
+ DataFetcher <?> dataFetcher = schema .getCodeRegistry ()
253
+ .getDataFetcher (coordinates , schema .getFieldDefinition (coordinates ));
254
+
255
+ assertThat (dataFetcher ).isInstanceOf (TrivialDataFetcher .class );
256
+ }
257
+
241
258
}
You can’t perform that action at this time.
0 commit comments