Skip to content

Commit 4f0720b

Browse files
authored
[docs] fix subscription docs and formatting (ExpediaGroup#1121)
1 parent 9709b1d commit 4f0720b

35 files changed

+132
-329
lines changed

website/docs/client/client-features.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,9 @@ Batch requests are sent as an array of individual GraphQL requests and clients e
191191
array of GraphQL responses. Each response is then deserialized to a corresponding result type.
192192

193193
```kotlin
194-
195194
val client = GraphQLKtorClient(url = URL("http://localhost:8080/graphql"))
196195
val firstQuery = FirstQuery(variables = FirstQuery.Variables(foo = "bar"))
197196
val secondQuery = SecondQuery(variables = SecondQuery.Variables(foo = "baz"))
198197

199198
val results: List<GraphQLResponse<*>> = client.execute(listOf(firstQuery, secondQuery))
200-
201199
```

website/docs/graphql-java-comparison.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ has been used and tested by many users.
1111
The most common way to create the schema in `graphql-java` is to first manually write the SDL file:
1212

1313
```graphql
14-
1514
schema {
1615
query: Query
1716
}
@@ -32,13 +31,11 @@ type Author {
3231
firstName: String!
3332
lastName: String!
3433
}
35-
3634
```
3735

3836
Then write the runtime code that matches this schema to build the `GraphQLSchema` object.
3937

4038
```kotlin
41-
4239
// Internal DB class, not schema class
4340
class Book(
4441
val id: ID,
@@ -94,7 +91,6 @@ val runtimeWiring = RuntimeWiring.newRuntimeWiring()
9491

9592
// Combine the types and runtime code together to make a schema
9693
val graphQLSchema: GraphQLSchema = schemaGenerator.makeExecutableSchema(typeDefinitionRegistry, runtimeWiring)
97-
9894
```
9995

10096
This means that there are two sources of truth for your schema and changes in either have to be reflected in both locations.
@@ -109,7 +105,6 @@ These errors will hopefully be caught by your build or automated tests, but it i
109105
All you need to do is write your schema code in a Kotlin class with public functions or properties.
110106

111107
```kotlin
112-
113108
private val books: List<Book> = booksFromDB()
114109
private val authors: List<Author> = authorsFromDB()
115110

@@ -136,7 +131,6 @@ class Author(
136131
val config = SchemaGeneratorConfig(supportedPackages = "com.example")
137132
val queries = listOf(TopLevelObject(Query()))
138133
val schema: GraphQLSchema = toSchema(config, queries)
139-
140134
```
141135

142136
This makes changes in code directly reflect to your schema and you can still produce the `GraphQLSchema` to print and export an SDL file.

website/docs/plugins/gradle-plugin-tasks.mdx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import TabItem from '@theme/TabItem';
1010
GraphQL Kotlin Gradle Plugin provides functionality to generate a lightweight GraphQL HTTP client and generate GraphQL
1111
schema directly from your source code.
1212

13-
> NOTE: This plugin is dependent on Kotlin compiler plugin as it generates Kotlin source code that needs to be compiled.
13+
:::info
14+
This plugin is dependent on Kotlin compiler plugin as it generates Kotlin source code that needs to be compiled.
15+
:::
1416

1517
## Usage
1618

@@ -58,18 +60,15 @@ apply(plugin = "com.expediagroup.graphql")
5860
Using plugins DSL syntax
5961

6062
```groovy
61-
6263
// build.gradle
6364
plugins {
6465
id 'com.expediagroup.graphql' version $graphQLKotlinVersion
6566
}
66-
6767
```
6868

6969
Or by using legacy plugin application
7070

7171
```groovy
72-
7372
// build.gradle
7473
buildscript {
7574
repositories {
@@ -83,7 +82,6 @@ buildscript {
8382
}
8483
8584
apply plugin: "com.expediagroup.graphql"
86-
8785
```
8886

8987
</TabItem>
@@ -109,7 +107,6 @@ tasks.
109107
<TabItem value="kotlin">
110108

111109
```kotlin
112-
113110
// build.gradle.kts
114111
import com.expediagroup.graphql.plugin.gradle.config.GraphQLScalar
115112
import com.expediagroup.graphql.plugin.gradle.config.GraphQLSerializer
@@ -148,14 +145,12 @@ graphql {
148145
packages = listOf("com.example")
149146
}
150147
}
151-
152148
```
153149

154150
</TabItem>
155151
<TabItem value="groovy">
156152

157153
```groovy
158-
159154
// build.gradle
160155
import com.expediagroup.graphql.plugin.gradle.config.GraphQLScalar
161156
import com.expediagroup.graphql.plugin.gradle.config.GraphQLSerializer
@@ -191,7 +186,6 @@ graphql {
191186
packages = ["com.example"]
192187
}
193188
}
194-
195189
```
196190

197191
</TabItem>
@@ -208,8 +202,7 @@ All `graphql-kotlin-gradle-plugin` tasks are grouped together under `GraphQL` ta
208202
`graphql`. You can find detailed information about GraphQL kotlin tasks by running Gradle `help --task <taskName>` task.
209203

210204
```shell
211-
212-
gradle --tasks
205+
$ gradle --tasks
213206

214207
GraphQL tasks
215208
-------------
@@ -218,7 +211,6 @@ graphqlGenerateClient - Generate HTTP client from the specified GraphQL queries.
218211
graphqlGenerateSDL - Generate GraphQL schema in SDL format.
219212
graphqlGenerateTestClient - Generate HTTP test client from the specified GraphQL queries.
220213
graphqlIntrospectSchema - Run introspection query against target GraphQL endpoint and save schema locally.--&gt;
221-
222214
```
223215

224216
### graphqlDownloadSDL
@@ -281,11 +273,9 @@ Service provider can be provided as part of your project, included in one of you
281273
provided artifact to the `graphqlSDL` configuration.
282274

283275
```kotlin
284-
285276
dependencies {
286277
graphqlSDL("com.expediagroup:graphql-kotlin-federated-hooks-provider:$graphQLKotlinVersion")
287278
}
288-
289279
```
290280

291281
### graphqlGenerateTestClient

website/docs/plugins/gradle-plugin-usage.mdx

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ Language (SDL) directly. `graphqlDownloadSDL` task requires target GraphQL serve
1616
be executed directly from the command line by explicitly passing `endpoint` parameter
1717

1818
```shell script
19-
2019
$ gradle graphqlDownloadSDL --endpoint="http://localhost:8080/sdl"
21-
2220
```
2321

2422
Task can also be explicitly configured in your Gradle build file
@@ -55,18 +53,18 @@ graphqlDownloadSDL {
5553
</TabItem>
5654
</Tabs>
5755

58-
&gt; NOTE: This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
59-
&gt; invoke it OR configure it as a dependency of some other task.
56+
:::info
57+
This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
58+
invoke it OR configure it as a dependency of some other task.
59+
:::
6060

6161
## Introspecting Schema
6262

6363
Introspection task requires target GraphQL server `endpoint` to be specified. Task can be executed directly from the
6464
command line by explicitly passing endpoint parameter
6565

6666
```shell script
67-
6867
$ gradle graphqlIntrospectSchema --endpoint="http://localhost:8080/graphql"
69-
7068
```
7169

7270
Task can also be explicitly configured in your Gradle build file
@@ -103,8 +101,10 @@ graphqlIntrospectSchema {
103101
</TabItem>
104102
</Tabs>
105103

106-
&gt; NOTE: This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
107-
&gt; invoke it OR configure it as a dependency of some other task.
104+
:::info
105+
This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
106+
invoke it OR configure it as a dependency of some other task.
107+
:::
108108

109109
## Generating Client
110110

@@ -114,9 +114,7 @@ configuration and storing GraphQL queries under `src/main/resources` directories
114114
command line by explicitly providing required properties.
115115

116116
```shell script
117-
118117
$ gradle graphqlGenerateClient --schemaFileName"mySchema.graphql" --packageName="com.example.generated"
119-
120118
```
121119

122120
Task can also be explicitly configured in your Gradle build file
@@ -166,15 +164,12 @@ custom [scalar converter](https://github.com/ExpediaGroup/graphql-kotlin/blob/ma
166164
For example given following custom scalar in our GraphQL schema
167165

168166
```graphql
169-
170167
scalar UUID
171-
172168
```
173169

174170
We can create a custom converter to automatically convert this custom scalar to `java.util.UUID`
175171

176172
```kotlin
177-
178173
package com.example
179174

180175
import com.expediagroup.graphql.client.converter.ScalarConverter
@@ -184,7 +179,6 @@ class UUIDScalarConverter : ScalarConverter<UUID> {
184179
override fun toScalar(rawValue: Any): UUID = UUID.fromString(rawValue.toString()
185180
override fun toJson(value: UUID): String = value.toString()
186181
}
187-
188182
```
189183

190184
Afterwards we need to configure our plugin to use this custom converter
@@ -291,9 +285,7 @@ configuration and storing GraphQL queries under `src/test/resources` directories
291285
command line by explicitly providing required properties.
292286

293287
```shell script
294-
295288
$ gradle graphqlGenerateTestClient --schemaFileName"mySchema.graphql" --packageName="com.example.generated"
296-
297289
```
298290

299291
Task can also be explicitly configured in your Gradle build file
@@ -335,7 +327,9 @@ graphqlGenerateTestClient {
335327
This will process all GraphQL queries located under `src/test/resources` and generate corresponding GraphQL Kotlin clients.
336328
Generated classes will be automatically added to the project test compile sources.
337329

338-
> NOTE: `graphqlGenerateTestClient` cannot be configured through the `graphql` extension and has to be explicitly configured.
330+
:::info
331+
`graphqlGenerateTestClient` cannot be configured through the `graphql` extension and has to be explicitly configured.
332+
:::
339333

340334
## Minimal Client Configuration Example
341335

@@ -688,8 +682,10 @@ graphqlGenerateSDL {
688682
</TabItem>
689683
</Tabs>
690684

691-
>NOTE: This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
692-
>invoke it OR configure it as a dependency of some other task.
685+
:::info
686+
This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
687+
invoke it OR configure it as a dependency of some other task.
688+
:::
693689

694690
## Generating SDL with Custom Hooks Provider Example
695691

@@ -776,5 +772,7 @@ dependencies {
776772
</TabItem>
777773
</Tabs>
778774

779-
>NOTE: This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
780-
>invoke it OR configure it as a dependency of some other task.
775+
:::info
776+
This task does not automatically configure itself to be part of your build lifecycle. You will need to explicitly
777+
invoke it OR configure it as a dependency of some other task.
778+
:::

website/docs/plugins/maven-plugin-goals.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ sidebar_label: Goals
77
GraphQL Kotlin Maven Plugin provides functionality to generate a lightweight GraphQL HTTP client and generate GraphQL
88
schema directly from your source code.
99

10-
> NOTE: This plugin is dependent on Kotlin compiler plugin as it generates Kotlin source code that needs to be compiled.
10+
:::info
11+
This plugin is dependent on Kotlin compiler plugin as it generates Kotlin source code that needs to be compiled.
12+
:::
1113

1214
## Goals
1315

website/docs/plugins/maven-plugin-usage.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ configuration options that are not available on command line.
101101
This will process all GraphQL queries located under `src/main/resources` and generate corresponding GraphQL Kotlin client
102102
data models. Generated classes will be automatically added to the project compile sources.
103103

104-
>NOTE: You might need to explicitly add generated clients to your project sources for your IDE to recognize them. See
105-
>[build-helper-maven-plugin](https://www.mojohaus.org/build-helper-maven-plugin/) for details.
104+
:::note
105+
You might need to explicitly add generated clients to your project sources for your IDE to recognize them. See
106+
[build-helper-maven-plugin](https://www.mojohaus.org/build-helper-maven-plugin/) for details.
107+
:::
106108

107109
## Generating Client with Custom Scalars
108110

@@ -272,8 +274,10 @@ configuration options that are not available on command line.
272274
This will process all GraphQL queries located under `src/test/resources` and generate corresponding GraphQL Kotlin test clients.
273275
Generated classes will be automatically added to the project test compile sources.
274276

275-
>NOTE: You might need to explicitly add generated test clients to your project test sources for your IDE to recognize them.
276-
>See [build-helper-maven-plugin](https://www.mojohaus.org/build-helper-maven-plugin/) for details.
277+
:::note
278+
You might need to explicitly add generated test clients to your project test sources for your IDE to recognize them.
279+
See [build-helper-maven-plugin](https://www.mojohaus.org/build-helper-maven-plugin/) for details.
280+
:::
277281

278282
## Minimal Configuration Example
279283

@@ -300,9 +304,11 @@ This generated schema is subsequently used to generate GraphQL client code based
300304
</plugin>
301305
```
302306

303-
>NOTE: Both `introspect-schema` and `generate-client` goals are bound to the same `generate-sources` Maven lifecycle phase.
304-
>As opposed to Gradle, Maven does not support explicit ordering of different goals bound to the same build phase. Maven
305-
>Mojos will be executed in the order they are defined in your `pom.xml` build file.
307+
:::info
308+
Both `introspect-schema` and `generate-client` goals are bound to the same `generate-sources` Maven lifecycle phase.
309+
As opposed to Gradle, Maven does not support explicit ordering of different goals bound to the same build phase. Maven
310+
Mojos will be executed in the order they are defined in your `pom.xml` build file.
311+
:::
306312

307313
## Complete Configuration Example
308314

website/docs/schema-generator/customizing-schemas/advanced-features.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,14 @@ allow you to link to those types from your custom `SchemaGeneratorHooks` impleme
1414
manually creating the underlying GraphQL type.
1515

1616
```kotlin
17-
1817
val myConfig = SchemaGeneratorConfig(supportedPackages = listOf("com.example"))
1918
val generator = SchemaGenerator(myConfig)
2019

2120
val schema = generator.generateSchema(
22-
queries = myQueries,
23-
additionalTypes = setOf(MyCustomObject::class.createType()),
24-
additionalInputTypes = setOf(MyCustomInputObject::class.createType())
21+
queries = myQueries,
22+
additionalTypes = setOf(MyCustomObject::class.createType()),
23+
additionalInputTypes = setOf(MyCustomInputObject::class.createType())
2524
)
26-
2725
```
2826

2927
### `SchemaGenerator::addAdditionalTypesWithAnnotation`

website/docs/schema-generator/customizing-schemas/deprecating-schema.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,22 @@ GraphQL schemas can have fields marked as deprecated. Instead of creating a cust
77
for the deprecated reason.
88

99
```kotlin
10-
1110
class SimpleQuery {
1211
@Deprecated(message = "this query is deprecated", replaceWith = ReplaceWith("shinyNewQuery"))
1312
fun simpleDeprecatedQuery(): Boolean = false
1413

1514
fun shinyNewQuery(): Boolean = true
1615
}
17-
1816
```
1917

2018
The above query would produce the following GraphQL schema:
2119

2220
```graphql
23-
2421
type Query {
2522
simpleDeprecatedQuery: Boolean! @deprecated(reason: "this query is deprecated, replace with shinyNewQuery")
2623

2724
shinyNewQuery: Boolean!
2825
}
29-
3026
```
3127

3228
While you can deprecate any fields/functions/classes in your Kotlin code, GraphQL only supports deprecation directive on

0 commit comments

Comments
 (0)