|
1 | 1 | package graphql.schema; |
2 | 2 |
|
3 | 3 | import graphql.Assert; |
| 4 | +import graphql.DeprecatedAt; |
4 | 5 | import graphql.Internal; |
5 | 6 | import graphql.PublicApi; |
6 | 7 | import graphql.schema.visibility.GraphqlFieldVisibility; |
@@ -56,11 +57,29 @@ public GraphqlFieldVisibility getFieldVisibility() { |
56 | 57 | * @param fieldDefinition the field definition |
57 | 58 | * |
58 | 59 | * @return the DataFetcher associated with this field. All fields have data fetchers |
| 60 | + * |
| 61 | + * @see #getDataFetcher(GraphQLObjectType, GraphQLFieldDefinition) |
| 62 | + * @deprecated This is confusing because {@link GraphQLInterfaceType}s cant have data fetchers. At runtime only a {@link GraphQLObjectType} |
| 63 | + * can be used to fetch a field. This method allows the mapping to be made, but it is never useful if an interface is passed in. |
59 | 64 | */ |
| 65 | + @Deprecated |
| 66 | + @DeprecatedAt("2023-05-13") |
60 | 67 | public DataFetcher<?> getDataFetcher(GraphQLFieldsContainer parentType, GraphQLFieldDefinition fieldDefinition) { |
61 | 68 | return getDataFetcherImpl(FieldCoordinates.coordinates(parentType, fieldDefinition), fieldDefinition, dataFetcherMap, systemDataFetcherMap, defaultDataFetcherFactory); |
62 | 69 | } |
63 | 70 |
|
| 71 | + /** |
| 72 | + * Returns a data fetcher associated with a field within an object type |
| 73 | + * |
| 74 | + * @param parentType the container type |
| 75 | + * @param fieldDefinition the field definition |
| 76 | + * |
| 77 | + * @return the DataFetcher associated with this field. All fields have data fetchers |
| 78 | + */ |
| 79 | + public DataFetcher<?> getDataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition) { |
| 80 | + return getDataFetcherImpl(FieldCoordinates.coordinates(parentType, fieldDefinition), fieldDefinition, dataFetcherMap, systemDataFetcherMap, defaultDataFetcherFactory); |
| 81 | + } |
| 82 | + |
64 | 83 | /** |
65 | 84 | * Returns a data fetcher associated with a field located at specified coordinates. |
66 | 85 | * |
@@ -242,11 +261,29 @@ private Builder markChanged(boolean condition) { |
242 | 261 | * @param fieldDefinition the field definition |
243 | 262 | * |
244 | 263 | * @return the DataFetcher associated with this field. All fields have data fetchers |
| 264 | + * |
| 265 | + * @see #getDataFetcher(GraphQLObjectType, GraphQLFieldDefinition) |
| 266 | + * @deprecated This is confusing because {@link GraphQLInterfaceType}s cant have data fetchers. At runtime only a {@link GraphQLObjectType} |
| 267 | + * can be used to fetch a field. This method allows the mapping to be made, but it is never useful if an interface is passed in. |
245 | 268 | */ |
| 269 | + @Deprecated |
| 270 | + @DeprecatedAt("2023-05-13") |
246 | 271 | public DataFetcher<?> getDataFetcher(GraphQLFieldsContainer parentType, GraphQLFieldDefinition fieldDefinition) { |
247 | 272 | return getDataFetcherImpl(FieldCoordinates.coordinates(parentType, fieldDefinition), fieldDefinition, dataFetcherMap, systemDataFetcherMap, defaultDataFetcherFactory); |
248 | 273 | } |
249 | 274 |
|
| 275 | + /** |
| 276 | + * Returns a data fetcher associated with a field within an object type |
| 277 | + * |
| 278 | + * @param parentType the container type |
| 279 | + * @param fieldDefinition the field definition |
| 280 | + * |
| 281 | + * @return the DataFetcher associated with this field. All fields have data fetchers |
| 282 | + */ |
| 283 | + public DataFetcher<?> getDataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition) { |
| 284 | + return getDataFetcherImpl(FieldCoordinates.coordinates(parentType, fieldDefinition), fieldDefinition, dataFetcherMap, systemDataFetcherMap, defaultDataFetcherFactory); |
| 285 | + } |
| 286 | + |
250 | 287 | /** |
251 | 288 | * Returns a data fetcher associated with a field located at specified coordinates. |
252 | 289 | * |
@@ -331,11 +368,31 @@ public Builder dataFetcher(FieldCoordinates coordinates, DataFetcher<?> dataFetc |
331 | 368 | * @param dataFetcher the data fetcher code for that field |
332 | 369 | * |
333 | 370 | * @return this builder |
| 371 | + * |
| 372 | + * @see #dataFetcher(GraphQLObjectType, GraphQLFieldDefinition, DataFetcher) |
| 373 | + * @deprecated This is confusing because {@link GraphQLInterfaceType}s cant have data fetchers. At runtime only a {@link GraphQLObjectType} |
| 374 | + * can be used to fetch a field. This method allows the mapping to be made, but it is never useful if an interface is passed in. |
334 | 375 | */ |
| 376 | + @Deprecated |
| 377 | + @DeprecatedAt("2023-05-13") |
335 | 378 | public Builder dataFetcher(GraphQLFieldsContainer parentType, GraphQLFieldDefinition fieldDefinition, DataFetcher<?> dataFetcher) { |
336 | 379 | return dataFetcher(FieldCoordinates.coordinates(parentType.getName(), fieldDefinition.getName()), dataFetcher); |
337 | 380 | } |
338 | 381 |
|
| 382 | + |
| 383 | + /** |
| 384 | + * Sets the data fetcher for a specific field inside an object type |
| 385 | + * |
| 386 | + * @param parentType the object type |
| 387 | + * @param fieldDefinition the field definition |
| 388 | + * @param dataFetcher the data fetcher code for that field |
| 389 | + * |
| 390 | + * @return this builder |
| 391 | + */ |
| 392 | + public Builder dataFetcher(GraphQLObjectType parentType, GraphQLFieldDefinition fieldDefinition, DataFetcher<?> dataFetcher) { |
| 393 | + return dataFetcher(FieldCoordinates.coordinates(parentType.getName(), fieldDefinition.getName()), dataFetcher); |
| 394 | + } |
| 395 | + |
339 | 396 | /** |
340 | 397 | * Called to place system data fetchers (eg Introspection fields) into the mix |
341 | 398 | * |
|
0 commit comments