You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GraphQL Kotlin is a collection of libraries, built on top of [graphql-java](https://www.graphql-java.com/), that aim to simplify running GraphQL in Kotlin
8
+
GraphQL Kotlin is a collection of libraries, built on top of [graphql-java](https://www.graphql-java.com/), that aim to simplify running GraphQL clients and servers in Kotlin.
9
+
10
+
Visit our [documentation site](https://expediagroup.github.io/graphql-kotlin) for more details.
9
11
10
12
## 📦 Modules
11
13
@@ -15,48 +17,25 @@ GraphQL Kotlin is a collection of libraries, built on top of [graphql-java](http
15
17
*[graphql-kotlin-schema-generator](/graphql-kotlin-schema-generator) - Code only GraphQL schema generation for Kotlin
16
18
*[graphql-kotlin-spring-server](/graphql-kotlin-spring-server) - Spring Boot auto-configuration library to create a GraphQL server
17
19
*[graphql-kotlin-types](/graphql-kotlin-types) - Core types used by both client and server
18
-
*[plugins](/plugins) - GraphQL Kotlin Gradle and Maven plugins
20
+
*[plugins](/plugins) - Gradle and Maven plugins
19
21
20
22
## ⌨️ Usage
21
23
22
-
Below is a basic example of how you can use [graphql-kotlin-spring-server](/graphql-kotlin-spring-server) to run a GraphQL server. For more details, see our documentation below or in the individual module READMEs
23
-
24
-
```kotlin
25
-
// Simple data class that is parsed by the schema generator
26
-
data classWidget(valid:Int, valvalue:String)
27
-
28
-
// Mark the class as a Spring GraphQL Query
29
-
@Component
30
-
classWidgetService : Query {
31
-
funwidgetById(id:Int): Widget?=null
32
-
}
33
-
34
-
@SpringBootApplication
35
-
classApplication
24
+
While all the individual modules of `graphql-kotlin` are published as stand-alone libraries, the most common use cases are running a server, and genereating a type-safe client.
36
25
37
-
funmain(args:Array<String>) {
38
-
runApplication<Application>(*args)
39
-
}
40
-
```
26
+
### Server Example
41
27
42
-
will generate a server at `/graphql` and `/playground` with the following schema
28
+
A basic example of how you can use [graphql-kotlin-spring-server](/graphql-kotlin-spring-server) to run a GraphQL server can be found on our [server documentation section](https://expediagroup.github.io/graphql-kotlin/docs/spring-server/spring-overview).
43
29
44
-
```graphql
45
-
typeQuery {
46
-
widgetById(id: Int!): Widget
47
-
}
30
+
### Client Example
48
31
49
-
typeWidget {
50
-
id: Int!
51
-
value: String!
52
-
}
53
-
```
32
+
A basic setup of [graphql-kotlin-client](/graphql-kotlin-client) can be found on our [client documentation section](https://expediagroup.github.io/graphql-kotlin/docs/client/client-overview).
More examples and documentation are available on our [documentation site](https://expediagroup.github.io/graphql-kotlin) hosted in GitHub Pages. We also have the [examples](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples) module which can be run locally for testing and shows example code using the libraries.
58
37
59
-
Ifyouhaveaquestionaboutsomethingyoucannotfindinourdocumentation, theindivdualmoduleREADMEs, or [javadocs](https://www.javadoc.io/doc/com.expediagroup/graphql-kotlin-schema-generator), feelfreeto [createanissue](https://github.com/ExpediaGroup/graphql-kotlin/issues) andtagitwiththequestionlabel.
38
+
If you have a question about something you can not find in our documentation, the indivdual module READMEs, or [javadocs](https://www.javadoc.io/doc/com.expediagroup/graphql-kotlin-schema-generator), feel free to contribute to the docs or [create an issue](https://github.com/ExpediaGroup/graphql-kotlin/issues) and tag it with the question label.
60
39
61
40
If you would like to contribute to our documentation see the [website](/website) directory for more information.
62
41
@@ -80,12 +59,12 @@ To get started, please fork the repo and checkout a new branch. You can then bui
80
59
./gradlew clean build
81
60
```
82
61
83
-
84
62
See more info in [CONTRIBUTING.md](CONTRIBUTING.md)
85
63
86
64
## 🛡️ Security
87
65
88
-
Formoreinfoonhowtocontacttheteamforsecurityissuesorthesupportedversionsthatrecievesecurityupdates, see [SECURITY.md](./.github/SECURITY.md).
66
+
For more info on how to contact the team for security issues or the supported versions that recieve security updates, see [SECURITY.md](./.github/SECURITY.md)
89
67
90
68
## ⚖️ License
69
+
91
70
This library is licensed under the [Apache License, Version 2.0](LICENSE)
`graphql-kotlin-federation` build on top of `graphql-kotlin-schema-generator` and adds a few extra methods and class to use to generate federation
42
+
compliant schemas.
43
+
44
+
### `toFederatedSchema`
45
+
46
+
47
+
Just like the basic [toSchema](../schema-generator/schema-generator-getting-started.md), `toFederatedSchema` accepts four parameters: `config`, `queries`, `mutations` and `subscriptions`.
48
+
The difference is that the `config` class is of type [FederatedSchemaGeneratorConfig](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-federation/src/main/kotlin/com/expediagroup/graphql/federation/FederatedSchemaGeneratorConfig.kt).
49
+
This class extends the [base configuration class](../schema-generator/customizing-schemas/generator-config.md) and adds some default logic. You can override the logic if needed, but do so with caution as you may no longer generate a spec compliant schema.
50
+
51
+
You can see the definition for `toFederatedSchema`[in the
For more details on how to create the context while using `graphql-kotlin-spring-server` see the [spring graphql context page](../../spring-server/spring-graphql-context.md).
57
+
55
58
### Customization
56
59
The context is injected into the execution through the `FunctionDataFetcher` class. If you want to customize the logic on how the context is determined, that is possible to override. See more details on the [Fetching Data documentation](./fetching-data)
GraphQL is strongly typed and any data that is not part of the schema is no longer automatically known by the clients. Relying on this information becomes an "undocumented" part of your API. As a result, by default, GraphQL query resolvers do not have access to the raw HTTP request and response objects.
7
+
8
+
That being said, there are some common use cases (like authorization) that require inspecting HTTP headers.
9
+
10
+
## GraphQL Context
11
+
12
+
The most common way to access the raw HTTP request and response objects is to process them when creating the GraphQLContext through the Spring bean [GraphQLContextFactory](./spring-graphql-context.md). Using the factory you can then extract the information from the incoming request and store it in the context so it can be accessed from any resolver.
Copy file name to clipboardExpand all lines: docs/spring-server/spring-overview.md
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,11 @@ title: Spring Server Overview
7
7
is a Spring Boot auto-configuration library that automatically configures beans required to start up a reactive GraphQL
8
8
web server.
9
9
10
-
This library is built on a [Spring WebFlux (reactive)](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html) stack which is a non-blocking alternative to a traditional [Spring Web MVC (servlet)](https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html) based stack. Since both frameworks utilize different threading models they cannot and should not be intermixed. When building a GraphQL server using `graphql-kotlin-spring-server` all your queries and mutations should follow one of the supported [asynchronous execution models](https://expediagroup.github.io/graphql-kotlin/docs/execution/async-models).
10
+
## WebFlux vs WebMVC
11
+
12
+
This library is built on a [Spring WebFlux (reactive)](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html) stack which is a non-blocking alternative to a traditional [Spring Web MVC (servlet)](https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html) based stack.
13
+
Since both frameworks utilize different threading models they cannot and should not be intermixed.
14
+
When building a GraphQL server using `graphql-kotlin-spring-server` all your queries and mutations should follow one of the supported [asynchronous execution models](https://expediagroup.github.io/graphql-kotlin/docs/execution/async-models).
`graphql-kotlin-spring-server` is a Spring Boot autoconfiguration library that automatically configures beans required to start up reactive GraphQL web server.
5
+
`graphql-kotlin-spring-server` is a Spring Boot autoconfiguration library that automatically configures beans required to start up reactive GraphQL web server.
@@ -31,15 +31,15 @@ At a minimum, in order for `graphql-kotlin-spring-server` to automatically confi
31
31
32
32
```yaml
33
33
graphql:
34
-
packages:
34
+
packages:
35
35
- "com.your.package"
36
36
```
37
37
38
38
In order to expose your queries, mutations and subscriptions in the GraphQL schema you simply need to implement corresponding marker interfaces and they will be automatically picked up by `graphql-kotlin-spring-server` autoconfiguration library.
0 commit comments