Skip to content

Commit 1dbdf28

Browse files
samuelAndalonSamuel Vazquez
and
Samuel Vazquez
authored
chore: start v9 development (#2041)
### 📝 Description Bumps the gradle version to 9.0.0-SNAPSHOT and cuts the v8 docs. Co-authored-by: Samuel Vazquez <[email protected]>
1 parent dd3ad23 commit 1dbdf28

File tree

81 files changed

+10976
-526
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+10976
-526
lines changed

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
group = com.expediagroup
2-
version = 8.0.0-SNAPSHOT
2+
version = 9.0.0-SNAPSHOT
33

44
# build config
55
org.gradle.caching=true

website/docusaurus.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ module.exports = {
2121
{
2222
docs: {
2323
editUrl: "https://github.com/ExpediaGroup/graphql-kotlin/tree/master/website",
24-
lastVersion: '7.x.x',
24+
lastVersion: '8.x.x',
2525
showLastUpdateAuthor: true,
2626
showLastUpdateTime: true,
2727
sidebarPath: require.resolve('./sidebars.js'),
2828
versions: {
2929
current: {
3030
label: 'pre-release',
31-
path: '8.x.x'
31+
path: '9.x.x'
3232
}
3333
}
3434
}

website/package-lock.json

+1,014-520
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"swizzle": "docusaurus swizzle"
1717
},
1818
"dependencies": {
19-
"@docusaurus/core": "^3.4.0",
20-
"@docusaurus/preset-classic": "^3.4.0",
21-
"@docusaurus/theme-mermaid": "^3.4.0"
19+
"@docusaurus/core": "^3.5.2",
20+
"@docusaurus/preset-classic": "^3.5.2",
21+
"@docusaurus/theme-mermaid": "^3.5.2"
2222
}
2323
}
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
id: blogs-and-videos
3+
title: Blogs & Videos
4+
---
5+
Here are some links to other blog posts and videos which may provide further examples and reading.
6+
7+
## graphql-kotlin
8+
9+
Articles and videos specifically about `graphql-kotlin`
10+
11+
- 📺  [Supercharge your GraphQL with Ktor and GraalVM (Dariusz Kuc)(KotlinConf 2023)](https://www.youtube.com/watch?v=gqQwTFeHOUU&list=PLlFc5cFwUnmwcJ7ZXyMmS70A9QFyUu1HI) (en)
12+
- 📝  [GraphQL Kotlin 6.0.0 Release](https://medium.com/expedia-group-tech/graphql-kotlin-6-0-0-release-2227fd066dcd)
13+
- 📝  [GraphQL Kotlin 4.0.0 Release](https://medium.com/expedia-group-tech/graphql-kotlin-4-0-0-release-eb87e150a192)
14+
- 📺  [Bootiful GraphQL with Kotlin (Dariusz Kuc, Guillaume Scheibel)(Spring One 2020)](https://www.youtube.com/watch?v=t9He4vHZC24) (en)
15+
- 📺  [Bootiful GraphQL with Kotlin (Dariusz Kuc)(GOTO Chicago 2020)](https://www.youtube.com/watch?v=1siPT1pTXFU) (en)
16+
- 📝  [Introducing GraphQL Kotlin Client](https://medium.com/expedia-group-tech/introducing-graphql-kotlin-client-b32dc3061a6f)
17+
- 📝  [Announcing graphql-kotlin 2.0!](https://medium.com/expedia-group-tech/graphql-kotlin-2-0-4006ea41f774)
18+
- 📺  [Bootiful GraphQL with Kotlin (Dariusz Kuc, Guillaume Scheibel)(KotlinConf 2019)](https://www.youtube.com/watch?v=7YJyPXjLdug&index=25) (en)
19+
- 📝  [Creating a Reactive GraphQL Server with Spring Boot and Kotlin](https://medium.com/expedia-group-tech/creating-a-reactive-graphql-server-with-spring-boot-and-kotlin-54aca7316470)
20+
- 📝  [Apollo Federation in a GraphQL Kotlin Server](https://medium.com/expedia-group-tech/apollo-federation-in-a-graphql-kotlin-server-115cea51607a)
21+
- 📝  [Creating GraphQL Schemas in Kotlin](https://medium.com/expedia-group-tech/creating-graphql-schemas-in-kotlin-aaaac0ab0672)
22+
- 📝  [Release of graphql-kotlin 1.0.0!](https://medium.com/expedia-group-tech/release-of-graphql-kotlin-1-0-0-791ad85d3116)
23+
- 📝  [graphql-kotlin: Generate a GraphQL schema from Kotlin code](https://medium.com/expedia-group-tech/graphql-kotlin-generate-a-graphql-schema-from-kotlin-code-21d1dc2f6e27)
24+
25+
## GraphQL
26+
27+
Articles and videos about how Expedia Group is using GraphQL
28+
29+
- 📝  [Expedia Group Case Study: Bootiful APIs With GraphQL and Kotlin](https://kotlinlang.org/lp/server-side/case-studies/expedia)
30+
- 📝  [Expedia Group Transforms Product Development with Apollo](https://www.apollographql.com/customers/expediagroup/)
31+
- 📺  [Creating a federated schema for a global company (Shane Myrick)](https://youtu.be/MuD3TAP0D9Y) (en)
32+
- 📺  [Migrer ses APIs vers GraphQL: pourquoi? comment! (Guillaume Scheibel)](https://youtu.be/IRIkpvJo95s) (fr)
33+
- 📺  [Migrate your APIs to GraphQL: how? and why! (Guillaume Scheibel)](https://youtu.be/IkPMpzQ-TRI) (en)
34+
- 📺  [Transforming customer experiences and your organization with GraphQL (Jim Gust, Dan Boerner)](https://youtu.be/Jt-ZD4zj4Ow) (en)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
---
2+
id: client-customization
3+
title: Client Customization
4+
---
5+
6+
7+
import Tabs from '@theme/Tabs';
8+
import TabItem from '@theme/TabItem';
9+
10+
## Ktor HTTP Client Customization
11+
12+
`GraphQLKtorClient` is a thin wrapper on top of [Ktor HTTP Client](https://ktor.io/docs/client.html) and supports fully
13+
asynchronous non-blocking communication. It is highly customizable and can be configured with any supported Ktor HTTP
14+
[engine](https://ktor.io/clients/http-client/engines.html) and [features](https://ktor.io/clients/http-client/features.html).
15+
16+
See [Ktor HTTP Client documentation](https://ktor.io/clients/index.html) for additional details.
17+
18+
### Global Client Customization
19+
20+
A single instance of `GraphQLKtorClient` can be used to handle many GraphQL operations. You can specify a custom instance
21+
of Ktor `HttpClient` and a target `GraphQLClientSerializer`.
22+
23+
The below example configures a new `GraphQLKtorClient` to use the `OkHttp` engine with custom timeouts, adds a default `X-MY-API-KEY`
24+
header to all requests, and enables basic logging of the requests.
25+
26+
```kotlin
27+
val okHttpClient = HttpClient(engineFactory = OkHttp) {
28+
engine {
29+
config {
30+
connectTimeout(10, TimeUnit.SECONDS)
31+
readTimeout(60, TimeUnit.SECONDS)
32+
writeTimeout(60, TimeUnit.SECONDS)
33+
}
34+
}
35+
defaultRequest {
36+
header("X-MY-API-KEY", "someSecretApiKey")
37+
}
38+
install(Logging) {
39+
logger = Logger.DEFAULT
40+
level = LogLevel.INFO
41+
}
42+
}
43+
val client = GraphQLKtorClient(
44+
url = URL("http://localhost:8080/graphql"),
45+
httpClient = okHttpClient
46+
)
47+
```
48+
49+
### Per Request Customization
50+
51+
Individual GraphQL requests can be customized through [HttpRequestBuilder](https://ktor.io/docs/request.html#customizing-requests).
52+
You can use this mechanism to specify custom headers, update target url to include custom query parameters, configure
53+
attributes that can be accessed from the pipeline features as well specify timeouts per request.
54+
55+
```kotlin
56+
val helloWorldQuery = HelloWorldQuery(variables = HelloWorldQuery.Variables(name = "John Doe"))
57+
val result = client.execute(helloWorldQuery) {
58+
header("X-B3-TraceId", "0123456789abcdef")
59+
}
60+
```
61+
62+
## Spring WebClient Customization
63+
64+
`GraphQLWebClient` is a thin wrapper on top of [Spring WebClient](https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/reactive/function/client/WebClient.html)
65+
that relies on Reactor Netty for fully asynchronous non-blocking communications. If you want to use Jetty instead you will
66+
need to exclude provided `io.projectreactor.netty:reactor-netty` dependency and instead add `org.eclipse.jetty:jetty-reactive-httpclient`
67+
dependency.
68+
69+
### Global Client Customization
70+
71+
A single instance of `GraphQLWebClient` can be used to handle many GraphQL operations and you can customize it by providing
72+
a custom instance of `WebClient.Builder`. See [Spring documentation](https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-webclient-customization)
73+
for additional details.
74+
75+
Example below configures `GraphQLWebClient` with custom timeouts and adds a default `X-MY-API-KEY` header to all requests.
76+
77+
```kotlin
78+
val httpClient: HttpClient = HttpClient.create()
79+
.option(ChannelOption.CONNECT_TIMEOUT_MILLIS, 10_000)
80+
.responseTimeout(Duration.ofMillis(10_000))
81+
val connector: ClientHttpConnector = ReactorClientHttpConnector(httpClient.wiretap(true))
82+
val webClientBuilder = WebClient.builder()
83+
.clientConnector(connector)
84+
.defaultHeader("X-MY-API-KEY", "someSecretApiKey")
85+
86+
val client = GraphQLWebClient(
87+
url = "http://localhost:8080/graphql",
88+
builder = webClientBuilder
89+
)
90+
```
91+
92+
### Per Request Customization
93+
94+
Individual GraphQL requests can be customized by providing `WebClient.RequestBodyUriSpec` lambda. You can use this mechanism
95+
to specify custom headers or include custom attributes or query parameters.
96+
97+
```kotlin
98+
val helloWorldQuery = HelloWorldQuery(variables = HelloWorldQuery.Variables(name = "John Doe"))
99+
val result = client.execute(helloWorldQuery) {
100+
header("X-B3-TraceId", "0123456789abcdef")
101+
}
102+
```
103+
104+
## Custom GraphQL Client
105+
106+
GraphQL Kotlin libraries provide generic a `GraphQLClient` interface as well as Ktor HTTP Client and Spring WebClient based
107+
reference implementations. Both `GraphQLKtorClient` and `GraphQLWebClient` are open classes which means you can also
108+
extend them to provide some custom `execute` logic.
109+
110+
```kotlin
111+
class CustomGraphQLClient(url: URL) : GraphQLKtorClient(url = url) {
112+
113+
override suspend fun <T: Any> execute(request: GraphQLClientRequest<T>, requestCustomizer: HttpRequestBuilder.() -> Unit): GraphQLClientResponse<T> {
114+
// custom init logic
115+
val result = super.execute(request, requestCustomizer)
116+
// custom finalize logic
117+
return result
118+
}
119+
}
120+
```
121+
122+
## Deprecated Field Usage
123+
124+
Build plugins will automatically fail generation of a client if any of the specified query files are referencing
125+
deprecated fields. This ensures that your clients have to explicitly opt-in into deprecated usage by specifying
126+
`allowDeprecatedFields` configuration option.

0 commit comments

Comments
 (0)