Skip to content

Commit e9cadc1

Browse files
smyrickShane Myrick
andauthored
Simplfy repeated information in the docs (#754)
* Simplfy repeated information in the docs * Remove expedia specific lockfile * PR comments * Reorder main gettings started sections * Update registry to public npm * Move npmrc to specific npm folders Co-authored-by: Shane Myrick <[email protected]>
1 parent a1124c4 commit e9cadc1

39 files changed

+3291
-3740
lines changed
File renamed without changes.

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Further instructions on how to add documentation content are in `website/README.
6363
All source files must contain the following license header. If you are using an IDE please add this as a copyright template for this project so that it will be added automatically.
6464

6565
```
66-
Copyright 2020 Expedia, Inc
66+
Copyright ${today.year} Expedia, Inc
6767
6868
Licensed under the Apache License, Version 2.0 (the "License");
6969
you may not use this file except in compliance with the License.

README.md

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
[![codecov](https://codecov.io/gh/ExpediaGroup/graphql-kotlin/branch/master/graph/badge.svg)](https://codecov.io/gh/ExpediaGroup/graphql-kotlin)
66
[![Slack](https://img.shields.io/badge/Slack-%23graphql--kotlin-ECB22E.svg?logo=data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgNTQgNTQiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48cGF0aCBkPSJNMTkuNzEyLjEzM2E1LjM4MSA1LjM4MSAwIDAgMC01LjM3NiA1LjM4NyA1LjM4MSA1LjM4MSAwIDAgMCA1LjM3NiA1LjM4Nmg1LjM3NlY1LjUyQTUuMzgxIDUuMzgxIDAgMCAwIDE5LjcxMi4xMzNtMCAxNC4zNjVINS4zNzZBNS4zODEgNS4zODEgMCAwIDAgMCAxOS44ODRhNS4zODEgNS4zODEgMCAwIDAgNS4zNzYgNS4zODdoMTQuMzM2YTUuMzgxIDUuMzgxIDAgM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OS43MTIgNTRhNS4zODEgNS4zODEgMCAwIDAgNS4zNzYtNS4zODdWMzQuMjVhNS4zODEgNS4zODEgMCAwIDAtNS4zNzYtNS4zODcgNS4zODEgNS4zODEgMCAwIDAtNS4zNzYgNS4zODciIGZpbGw9IiNFMDFFNUEiLz48L2c+PC9zdmc+&labelColor=611f69)](https://kotlinlang.slack.com/messages/graphql-kotlin/)
77

8-
GraphQL Kotlin is a collection of libraries built on top of [graphql-java](https://www.graphql-java.com/) that aim to simplify running a GraphQL server 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 in Kotlin
99

1010
## 📦 Modules
1111

@@ -19,25 +19,27 @@ GraphQL Kotlin is a collection of libraries built on top of [graphql-java](https
1919

2020
## ⌨️ Usage
2121

22-
Below is a basic example of how [graphql-kotlin-schema-generator](/graphql-kotlin-schema-generator) converts your Kotlin code into a GraphQL schema. For more details, see our documentation below or in the individual module READMEs
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
2323

2424
```kotlin
25+
// Simple data class that is parsed by the schema generator
2526
data class Widget(val id: Int, val value: String)
2627

27-
class WidgetService {
28-
fun widgetById(id: Int): Widget? {
29-
// grabs widget from a data source, might return null
30-
}
28+
// Mark the class as a Spring GraphQL Query
29+
@Component
30+
class WidgetService : Query {
31+
fun widgetById(id: Int): Widget? = null
3132
}
3233

33-
// Generate the schema
34-
val config = SchemaGeneratorConfig(supportedPackages = listOf("org.example"))
35-
val queries = listOf(TopLevelObject(WidgetService()))
34+
@SpringBootApplication
35+
class Application
3636

37-
toSchema(config, queries)
37+
fun main(args: Array<String>) {
38+
runApplication<Application>(*args)
39+
}
3840
```
3941

40-
will generate
42+
will generate a server at `/graphql` and `/playground` with the following schema
4143

4244
```graphql
4345
type Query {
@@ -50,23 +52,6 @@ type Widget {
5052
}
5153
```
5254

53-
Then using [graphql-kotlin-spring-server](/graphql-kotlin-spring-server) you can easily make your schema available as a GraphQL server with Spring Boot.
54-
55-
```kotlin
56-
// Mark the class as a Spring GraphQL Query
57-
@Component
58-
class WidgetService : Query {
59-
fun widgetById(id: Int): Widget? {}
60-
}
61-
62-
@SpringBootApplication
63-
class Application
64-
65-
fun main(args: Array<String>) {
66-
runApplication<Application>(*args)
67-
}
68-
```
69-
7055
## 📋 Documentation
7156

7257
Examples and documentation are available on our [documentation site](https://expediagroup.github.io/graphql-kotlin) hosted in GitHub Pages.
@@ -79,12 +64,12 @@ If you would like to contribute to our documentation see the [website](/website)
7964

8065
This project is part of Expedia Group Open Source but also maintained by a dedicated team
8166

82-
* Expedia Group
67+
* Expedia Group OSS
8368
* https://expediagroup.github.io
8469
* oss@expediagroup.com
8570

86-
* `@ExpediaGroup/graphql-kotlin-committers`
87-
* Tag us in an issue on Github
71+
* GraphQL Kotlin Committers
72+
* Github team: `@ExpediaGroup/graphql-kotlin-committers`
8873
* We also have a public channel, ([#graphql-kotlin](https://app.slack.com/client/T09229ZC6/CQLNT7B29)), open on the Kotlin Slack instance. See the info [here on how to join this slack instance](https://slack.kotlinlang.org/)
8974

9075
## ✏️ Contributing
@@ -98,5 +83,9 @@ To get started, please fork the repo and checkout a new branch. You can then bui
9883

9984
See more info in [CONTRIBUTING.md](CONTRIBUTING.md)
10085

86+
## 🛡️ Security
87+
88+
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+
10190
## ⚖️ License
10291
This library is licensed under the [Apache License, Version 2.0](LICENSE)

docs/blogs-and-videos.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ Articles and videos specifically about `graphql-kotlin`
1616
* 📝 [Apollo Federation in a GraphQL Kotlin Server](https://medium.com/expedia-group-tech/apollo-federation-in-a-graphql-kotlin-server-115cea51607a)
1717
* 📝 [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)
1818
* 📺 [Bootiful GraphQL with Kotlin (Dariusz Kuc, Guillaume Scheibel)](https://www.youtube.com/watch?v=7YJyPXjLdug&amp;index=25) (en)
19+
* 📝 [🎉 Announcing graphql-kotlin 2.0!](https://medium.com/expedia-group-tech/graphql-kotlin-2-0-4006ea41f774)
20+
* 📝 [Introducing GraphQL Kotlin Client](https://medium.com/expedia-group-tech/introducing-graphql-kotlin-client-b32dc3061a6f)
1921

2022
#### GraphQL
2123
Articles and videos about how Expedia Group is using GraphQL

docs/examples.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ id: examples
33
title: Examples
44
---
55

6+
A collection of example apps that use graphql-kotlin libraries to test and demonstrate usages can be found in the [examples module](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples).
7+
8+
## Client Example
9+
10+
A `graphql-kotlin-client` can be generated using the Maven and Gradle plugins in `graphql-kotlin-plugins`. For examples see the [examples/client](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples/client) folder.
11+
612
## Spring Server Example
713

814
One way to run a GraphQL server is with [Spring Boot](https://github.com/spring-projects/spring-boot). A sample Spring

docs/getting-started.md

Lines changed: 22 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,22 @@ id: getting-started
33
title: Getting Started
44
---
55

6-
GraphQL Kotlin is a collection of libraries built on top of [graphql-java](https://www.graphql-java.com/) that aim to simplify running a GraphQL server in Kotlin
6+
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
77

88
## Modules
99

10+
* [examples](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples)
11+
&mdash; Example apps that use graphql-kotlin libraries to test and demonstrate usages
1012
* [graphql-kotlin-client](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/graphql-kotlin-client) ([Javadoc](https://www.javadoc.io/doc/com.expediagroup/graphql-kotlin-client))
1113
&mdash; Lightweight GraphQL Kotlin HTTP client
1214
* [graphql-kotlin-schema-generator](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/graphql-kotlin-schema-generator) ([Javadoc](https://www.javadoc.io/doc/com.expediagroup/graphql-kotlin-schema-generator))
1315
&mdash; Code only GraphQL schema generation for Kotlin
1416
* [graphql-kotlin-federation](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/graphql-kotlin-federation) ([Javadoc](https://www.javadoc.io/doc/com.expediagroup/graphql-kotlin-federation))
1517
&mdash; Schema generator extension to build federated GraphQL schemas
1618
* [graphql-kotlin-spring-server](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/graphql-kotlin-spring-server) ([Javadoc](https://www.javadoc.io/doc/com.expediagroup/graphql-kotlin-spring-server))
17-
&mdash; Spring Boot auto-configuration library to create GraphQL web app
18-
* [examples](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/examples)
19-
&mdash; Example apps that use graphql-kotlin libraries to test and demonstrate usages
19+
&mdash; Spring Boot auto-configuration library to create GraphQL server
20+
* [graphql-kotlin-types](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/graphql-kotlin-types) ([Javadoc](https://www.javadoc.io/doc/com.expediagroup/graphql-kotlin-types))
21+
&mdash; Core types used by both client and server
2022
* [plugins](https://github.com/ExpediaGroup/graphql-kotlin/tree/master/plugins)
2123
&mdash; GraphQL Kotlin Gradle and Maven plugins
2224

@@ -30,96 +32,44 @@ Additional resources
3032

3133
## Installation
3234

33-
Using a JVM dependency manager, simply link `graphql-kotlin-schema-generator` to your project. You can see the latest
35+
Using a JVM dependency manager, simply link any `graphql-kotlin-*` library to your project. You can see the latest
3436
version and other examples in [Sonatype Central
35-
Repository](https://search.maven.org/artifact/com.expediagroup/graphql-kotlin-schema-generator)
37+
Repository](https://search.maven.org/artifact/com.expediagroup/graphql-kotlin-spring-server)
3638

3739
### Maven
3840

3941
```xml
4042
<dependency>
4143
<groupId>com.expediagroup</groupId>
42-
<artifactId>graphql-kotlin-schema-generator</artifactId>
44+
<artifactId>graphql-kotlin-spring-server</artifactId>
4345
<version>${latestVersion}</version>
4446
</dependency>
4547
```
4648

4749
### Gradle
4850

4951
```groovy
50-
compile(group: 'com.expediagroup', name: 'graphql-kotlin-schema-generator', version: "$latestVersion")
51-
```
52-
53-
## Generating a schema
54-
55-
`graphql-kotlin-schema-generator` provides a single function, `toSchema`, to generate a schema from Kotlin objects.
56-
57-
```kotlin
58-
class Query {
59-
fun getNumber() = 1
60-
}
61-
62-
val config = SchemaGeneratorConfig(listOf("com.expediagroup"))
63-
val queries = listOf(TopLevelObject(Query()))
64-
val schema: GraphQLSchema = toSchema(config = config, queries = queries)
52+
compile(group: 'com.expediagroup', name: 'graphql-kotlin-spring-server', version: "$latestVersion")
6553
```
6654

67-
generates a `GraphQLSchema` with IDL that looks like this:
55+
## Generating a Schema
6856

69-
```graphql
70-
schema {
71-
query: Query
72-
}
57+
While we have included a server implementation, you can use `graphql-kotlin-schema-generator` to generate a schema from Kotlin code and expose it with any server library.
7358

74-
type Query {
75-
getNumber: Int!
76-
}
77-
```
59+
See the docs in [Schema Generator Getting Started](./schema-generator/schema-generator-getting-started.md).
7860

79-
The `GraphQLSchema` generated can be used to expose a GraphQL API endpoint.
61+
### Federation
8062

81-
### `toSchema`
63+
Using `graphql-kotlin-federation`, you can generate an [Apollo Federation](https://www.apollographql.com/docs/apollo-server/federation/federation-spec/) complaint schema.
8264

83-
This function accepts four arguments: `config`, `queries`, `mutations` and `subscriptions`. The `queries`, `mutations`
84-
and `subscriptions` are a list of `TopLevelObject`s and will be used to generate corresponding GraphQL root types. See
85-
below on why we use this wrapper class. The `config` contains all the extra information you need to pass, including
86-
custom hooks, supported packages, and name overrides. See the full documentation: [Spring Server Overview](spring-server/spring-overview).
65+
See the docs in [Apollo Federation](./federated/apollo-federation.md).
8766

88-
You can see the definition for `toSchema` [in the
89-
source](https://github.com/ExpediaGroup/graphql-kotlin/blob/master/graphql-kotlin-schema-generator/src/main/kotlin/com/expediagroup/graphql/toSchema.kt)
67+
## Running a Server
68+
`graphql-kotlin-spring-server` is a combination of the schema generator, fedeation, and server libraries. If you are looking to run a GraphQL server, this is the place to start.
9069

91-
### Class `TopLevelObject`
70+
See the docs in [Spring Server Overview](./spring-server/spring-overview.md).
9271

93-
`toSchema` uses Kotlin reflection to build a GraphQL schema from given classes using `graphql-java`'s schema builder. We
94-
don't just pass a `KClass` though, we have to actually pass an object, because the functions on the object are
95-
transformed into the data fetchers. In most cases, a `TopLevelObject` can be constructed with just an object:
72+
## Creating a Client
73+
`graphql-kotlin-plugins` can be used to generate a `graphql-kotlin-client` from an existing schema that is easy to use and type-safe.
9674

97-
```kotlin
98-
class Query {
99-
fun getNumber() = 1
100-
}
101-
102-
val topLevelObject = TopLevelObject(Query())
103-
104-
toSchema(config = config, queries = listOf(topLevelObject))
105-
```
106-
107-
In the above case, `toSchema` will use `topLevelObject::class` as the reflection target, and `Query` as the data fetcher
108-
target.
109-
110-
In a lot of cases, such as with Spring AOP, the object (or bean) being used to generate a schema is a dynamic proxy. In
111-
this case, `topLevelObject::class` is not `Query`, but rather a generated class that will confuse the schema generator.
112-
To specify the `KClass` to use for reflection on a proxy, pass the class to `TopLevelObject`:
113-
114-
```kotlin
115-
@Component
116-
class Query {
117-
@Timed
118-
fun getNumber() = 1
119-
}
120-
121-
val query = getObjectFromBean()
122-
val customDef = TopLevelObject(query, Query::class)
123-
124-
toSchema(config, listOf(customDef))
125-
```
75+
See the docs in [Client Overview](./client/client-overview.md).

docs/customizing-schemas/advanced-features.md renamed to docs/schema-generator/customizing-schemas/advanced-features.md

File renamed without changes.

docs/customizing-schemas/deprecating-schema.md renamed to docs/schema-generator/customizing-schemas/deprecating-schema.md

File renamed without changes.
File renamed without changes.

docs/customizing-schemas/documenting-fields.md renamed to docs/schema-generator/customizing-schemas/documenting-fields.md

File renamed without changes.

0 commit comments

Comments
 (0)