Skip to content

Commit 77fd1d9

Browse files
authored
Update DataFetchingEnvironment docs (#577)
* Update DataFetchingEnvironment docs * Update other graphql-java v13 links:
1 parent bc33bac commit 77fd1d9

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

docs/execution/data-fetching-environment.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,43 @@ id: data-fetching-environment
33
title: Data Fetching Environment
44
---
55
Each resolver has access to a `DataFetchingEnvironment` that provides additional information about the currently executed query including information about what data is requested
6-
as well as details about current execution state. For more details on the `DataFetchingEnvironment` please refer to [graphql-java documentation](https://www.graphql-java.com/documentation/v13/data-fetching/)
6+
as well as details about current execution state. For more details on the `DataFetchingEnvironment` please refer to [graphql-java documentation](https://www.graphql-java.com/documentation/v14/data-fetching/)
77

88
You can access this info by including the `DataFetchingEnvironment` as one of the arguments to a Kotlin function. This argument will be automatically populated and injected
99
during the query execution but will not be included in the schema definition.
1010

1111
```kotlin
1212
class Query {
13-
fun printEnvironmentInfo(environment: DataFetchingEnvironment): String {
14-
// access env data
15-
}
13+
fun printEnvironmentInfo(parentField: String): MyObject = MyObject()
14+
}
15+
16+
class MyObject {
17+
fun printParentField(childField: String, environment: DataFetchingEnvironment): String {
18+
val parentField = environment.executionStepInfo.parent.getArgument("parentField")
19+
return "The parentField was $parentField and the childField was $childField"
20+
}
1621
}
1722
```
1823

1924
This will produce the following schema
2025

2126
```graphql
2227
type Query {
23-
printEnvironmentInfo: String!
28+
printEnvironmentInfo(parentField: String!): MyObject!
29+
}
30+
31+
type MyObject {
32+
printParentField(childField: String!): String!
33+
}
34+
```
35+
36+
Then the following query would return `"The parentField was foo and the childField was bar"`
37+
38+
```graphql
39+
{
40+
printEnvironmentInfo(parentField: "foo") {
41+
printParentField(childField: "bar")
42+
}
2443
}
2544
```
2645

docs/execution/exceptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Exceptions and Partial Data
44
---
55

66
Exceptions thrown during execution of a query will result in a GraphQLError that is added to a list of errors of the result. See
7-
[graphql-java documentation](https://www.graphql-java.com/documentation/v13/execution/) for more details on how to customize your exception handling.
7+
[graphql-java documentation](https://www.graphql-java.com/documentation/v14/execution/) for more details on how to customize your exception handling.
88

99
### Partial Data
1010

docs/execution/fetching-data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Fetching Data
66
Each field exposed through a GraphQL query has a corresponding resolver (aka data fetcher) associated with it. `graphql-kotlin-schema-generator` generates GraphQL schema
77
directly from the source code automatically mapping all the fields either to use
88
[FunctionDataFetcher](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/execution/FunctionDataFetcher.kt)
9-
to resolve underlying functions or a [PropertyDataFetcher](https://www.graphql-java.com/documentation/v13/data-fetching/) to read a value from an underlying Kotlin property.
9+
to resolve underlying functions or a [PropertyDataFetcher](https://www.graphql-java.com/documentation/v14/data-fetching/) to read a value from an underlying Kotlin property.
1010

1111
While all the fields in a GraphQL query are resolved independently to produce a final result, whether field is backed by a function or a property can have significant
1212
performance repercussions. For example, given the following schema:

docs/spring-server/spring-beans.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ can be customized by providing custom beans in your application context. See sec
2323
|:---------------------------------|:------------|
2424
| ContextWebFilter | Default web filter that populates GraphQL context in the reactor subscriber context. |
2525
| DataFetcherExceptionHandler | GraphQL exception handler used from the various execution strategies, defaults to [KotlinDataFetcherExceptionHandler](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/exception/KotlinDataFetcherExceptionHandler.kt). |
26-
| DataLoaderRegistryFactory | Factory used to create DataLoaderRegistry instance per query execution. See [graphql-java documentation](https://www.graphql-java.com/documentation/v13/batching/) for more details. |
27-
| GraphQL | GraphQL query execution engine generated using `GraphQLSchema` with default async execution strategies. GraphQL engine can be customized by optionally providing a list of [Instrumentation](https://www.graphql-java.com/documentation/v13/instrumentation/) beans (which can be ordered by implementing Spring Ordered interface), [ExecutionIdProvider](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/ExecutionIdProvider.java) and [PreparsedDocumentProvider](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/preparsed/PreparsedDocumentProvider.java) in the application context. |
26+
| DataLoaderRegistryFactory | Factory used to create DataLoaderRegistry instance per query execution. See [graphql-java documentation](https://www.graphql-java.com/documentation/v14/batching/) for more details. |
27+
| GraphQL | GraphQL query execution engine generated using `GraphQLSchema` with default async execution strategies. GraphQL engine can be customized by optionally providing a list of [Instrumentation](https://www.graphql-java.com/documentation/v14/instrumentation/) beans (which can be ordered by implementing Spring Ordered interface), [ExecutionIdProvider](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/ExecutionIdProvider.java) and [PreparsedDocumentProvider](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/execution/preparsed/PreparsedDocumentProvider.java) in the application context. |
2828
| GraphQLContextFactory | Factory used by context WebFilter to generate GraphQL context based on the incoming request. GraphQL context can be any object. Defaults to empty [GraphQLContext](https://github.com/graphql-java/graphql-java/blob/master/src/main/java/graphql/GraphQLContext.java). |
2929
| QueryHandler | Handler invoked from GraphQL query route that executes the incoming request, defaults to [SimpleQueryHandler](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/execution/QueryHandler.kt). |
3030
| SubscriptionHandler | Web socket handler for executing GraphQL subscriptions, defaults to [SimpleSubscriptionHandler](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-spring-server/src/main/kotlin/com/expediagroup/graphql/spring/execution/SubscriptionHandler.kt#L49).<br><br>_Created only if `Subscription` bean is available in the context._ |

docs/writing-schemas/scalars.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ extended scalar types provided by `graphql-java`.
2020
| `kotlin.BigDecimal` | `BigDecimal` |
2121
| `kotlin.Char` | `Char` |
2222

23-
> NOTE: Extended GraphQL scalar types provided by `graphql-java` are generated as custom scalar types. When using those custom scalar types your GraphQL clients will have to know how to correctly parse and serialize them. See `graphql-java` [documentation](https://www.graphql-java.com/documentation/v13/scalars/) for more details.
23+
> NOTE: Extended GraphQL scalar types provided by `graphql-java` are generated as custom scalar types. When using those custom scalar types your GraphQL clients will have to know how to correctly parse and serialize them. See `graphql-java` [documentation](https://www.graphql-java.com/documentation/v14/scalars/) for more details.
2424
2525
## ID
2626

0 commit comments

Comments
 (0)