Skip to content

Commit 4467bc1

Browse files
dariuszkucShane Myrick
authored and
Shane Myrick
committed
update library structure (ExpediaGroup#255)
* update library structure Changes to a multi module project with `graphql-kotlin-schema-generator` (previously released as `graphql-kotlin`) and `graphql-kotlin-spring-example` (previously standalone project). * fix travis build * update README to reflect new structure * skip generating javadoc for example app
1 parent 74652e5 commit 4467bc1

File tree

177 files changed

+469
-444
lines changed

Some content is hidden

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

177 files changed

+469
-444
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ before_install:
1515

1616
script:
1717
- ./mvnw install
18-
- ./mvnw -f example/pom.xml verify
1918

2019
deploy:
2120
provider: script

.travis/update-version.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,11 @@ setup_git() {
88
}
99

1010
update_version() {
11-
12-
exampleProperty="graphql-kotlin.version"
13-
1411
# Push the new tag with `-SNAPSHOT` as the current version
1512
mvn --settings .travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.7:set -DnewVersion="${TRAVIS_TAG}-SNAPSHOT"
1613

1714
# Increment the patch version
1815
mvn --settings .travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.7:set -DnextSnapshot=true
19-
20-
# Pull the value from the pom
21-
NEW_VERSION=$(mvn --settings .travis/settings.xml help:evaluate -Dexpression=project.version -q -DforceStdout)
22-
23-
# Update the example version
24-
cd example/
25-
mvn --settings ../.travis/settings.xml org.codehaus.mojo:versions-maven-plugin:2.7:set-property -Dproperty=${exampleProperty} -DnewVersion=${NEW_VERSION}
26-
cd ../
2716
}
2817

2918
commit_files() {
@@ -32,7 +21,7 @@ commit_files() {
3221
git checkout -b ${NEW_VERSION}
3322

3423
# Stage the modified files
35-
git add pom.xml example/pom.xml
24+
git add pom.xml */pom.xml
3625

3726
# Create a new commit with a custom build message and Travis build number for reference
3827
git commit -m "build: $NEW_VERSION (Travis Build $TRAVIS_BUILD_NUMBER)"

README.md

Lines changed: 5 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -6,98 +6,15 @@
66
[![Javadocs](https://img.shields.io/maven-central/v/com.expedia/graphql-kotlin.svg?label=javadoc&colorB=brightgreen)](https://www.javadoc.io/doc/com.expedia/graphql-kotlin)
77
[![Awesome Kotlin Badge](https://kotlin.link/awesome-kotlin.svg)](https://github.com/KotlinBy/awesome-kotlin)
88

9-
Most GraphQL libraries require developers to maintain two sources of truth for their GraphQL API: the schema and the corresponding code (data fetchers or resolvers, and types). Given the similarities between Kotlin and GraphQL, such as the ability to define nullable/non-nullable types, a schema can be generated from Kotlin code without any separate schema specification. `graphql-kotlin` builds upon `graphql-java` to allow code-only, or resolver-first, GraphQL services to be built.
9+
GraphQL Kotlin consists of number of libraries that aim to simplify GraphQL integration for Kotlin applications.
1010

11-
For information on GraphQL, please visit [the GraphQL website](https://graphql.org/).
11+
## Modules
1212

13-
For information on `graphql-java`, please visit [GraphQL Java](https://www.graphql-java.com/documentation/latest/).
14-
15-
## Installation
16-
17-
Using a JVM dependency manager, simply link `graphql-kotlin` to your project.
18-
19-
With Maven:
20-
21-
```xml
22-
<dependency>
23-
<groupId>com.expedia</groupId>
24-
<artifactId>graphql-kotlin</artifactId>
25-
<version>${latestVersion}</version>
26-
</dependency>
27-
```
28-
29-
With Gradle:
30-
31-
```groovy
32-
compile(group: 'com.expedia', name: 'graphql-kotlin', version: "$latestVersion")
33-
```
34-
35-
## Usage
36-
37-
38-
```kotlin
39-
// Your existing Kotlin code
40-
41-
data class Widget(val id: Int, val value: String)
42-
43-
class WidgetService {
44-
fun widgetById(id: Int): Widget? {
45-
// grabs widget from a data source, might return null
46-
}
47-
48-
@Deprecated("Use widgetById")
49-
fun widgetByValue(value: String): Widget? {
50-
// grabs widget from a deprecated data source, might return null
51-
}
52-
}
53-
54-
class WidgetUpdater {
55-
fun saveWidget(value: String): Widget {
56-
// Create and save a new widget, returns non-null
57-
}
58-
}
59-
60-
// Generate the schema
61-
62-
val config = SchemaGeneratorConfig(supportedPackages = listOf("org.example"))
63-
val queries = listOf(TopLevelObject(WidgetService()))
64-
val mutations = listOf(TopLevelObject(WidgetUpdater()))
65-
66-
toSchema(config, queries, mutations)
67-
```
68-
69-
will generate
70-
71-
```graphql
72-
schema {
73-
query: Query
74-
mutation: Mutation
75-
}
76-
77-
type Query {
78-
widgetById(id: Int!): Widget
79-
80-
widgetByValue(vale: String!): Widget @deprecated(reason: "Use widgetById")
81-
}
82-
83-
type Mutation {
84-
saveWidget(value: String!): Widget!
85-
}
86-
87-
type Widget {
88-
id: Int!
89-
value: String!
90-
}
91-
```
13+
* [graphql-kotlin-schema-generator](graphql-kotlin-schema-generator/README.md) - code only GraphQL schema generation for Kotlin
14+
* [graphql-kotlin-spring-example](graphql-kotlin-spring-example/README.md) - example SpringBoot app that uses GraphQL Kotlin schema generator
9215

9316
## Documentation
9417

95-
There are more examples and documention in our [Uncyclo](https://github.com/ExpediaDotCom/graphql-kotlin/wiki) or you can view the [javadocs](https://www.javadoc.io/doc/com.expedia/graphql-kotlin) for all published versions.
18+
Examples and documentation is available on our [Uncyclo](https://github.com/ExpediaDotCom/graphql-kotlin/wiki) or you can view the [javadocs](https://www.javadoc.io/doc/com.expedia/graphql-kotlin) for all published versions.
9619

9720
If you have a question about something you can not find in our wiki or javadocs, feel free to [create an issue](https://github.com/ExpediaDotCom/graphql-kotlin/issues) and tag it with the question label.
98-
99-
## Example
100-
101-
One way to run a GraphQL server is with Spring Boot. A sample Spring Boot app that uses [Spring Webflux](https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html) together with `graphql-kotlin` and [graphql-playground](https://github.com/prisma/graphql-playground) is provided in the [example folder](https://github.com/ExpediaDotCom/graphql-kotlin/tree/master/example). All the examples used in this documentation should be available in the sample app.
102-
103-
In order to run it you can run [Application.kt](https://github.com/ExpediaDotCom/graphql-kotlin/blob/master/example/src/main/kotlin/com.expedia.graphql.sample/Application.kt) directly from your IDE. Alternatively you can also use the Spring Boot maven plugin by running `mvn spring-boot:run` from the command line. Once the app has started you can explore the example schema by opening GraphiQL endpoint at [http://localhost:8080/playground](http://localhost:8080/playground).

example/pom.xml

Lines changed: 0 additions & 139 deletions
This file was deleted.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# GraphQL Kotlin Schema Generator
2+
3+
Most GraphQL libraries require developers to maintain two sources of truth for their GraphQL API: the schema and the corresponding code (data fetchers or resolvers, and types). Given the similarities between Kotlin and GraphQL, such as the ability to define nullable/non-nullable types, a schema can be generated from Kotlin code without any separate schema specification. `graphql-kotlin` builds upon `graphql-java` to allow code-only, or resolver-first, GraphQL services to be built.
4+
5+
For information on GraphQL, please visit [the GraphQL website](https://graphql.org/).
6+
7+
For information on `graphql-java`, please visit [GraphQL Java](https://www.graphql-java.com/documentation/latest/).
8+
9+
## Installation
10+
11+
Using a JVM dependency manager, simply link `graphql-kotlin-schema-generator` to your project.
12+
13+
With Maven:
14+
15+
```xml
16+
<dependency>
17+
<groupId>com.expedia</groupId>
18+
<artifactId>graphql-kotlin-schema-generator</artifactId>
19+
<version>${latestVersion}</version>
20+
</dependency>
21+
```
22+
23+
With Gradle:
24+
25+
```groovy
26+
compile(group: 'com.expedia', name: 'graphql-kotlin-schema-generator', version: "$latestVersion")
27+
```
28+
29+
## Usage
30+
31+
32+
```kotlin
33+
// Your existing Kotlin code
34+
35+
data class Widget(val id: Int, val value: String)
36+
37+
class WidgetService {
38+
fun widgetById(id: Int): Widget? {
39+
// grabs widget from a data source, might return null
40+
}
41+
42+
@Deprecated("Use widgetById")
43+
fun widgetByValue(value: String): Widget? {
44+
// grabs widget from a deprecated data source, might return null
45+
}
46+
}
47+
48+
class WidgetUpdater {
49+
fun saveWidget(value: String): Widget {
50+
// Create and save a new widget, returns non-null
51+
}
52+
}
53+
54+
// Generate the schema
55+
56+
val config = SchemaGeneratorConfig(supportedPackages = listOf("org.example"))
57+
val queries = listOf(TopLevelObject(WidgetService()))
58+
val mutations = listOf(TopLevelObject(WidgetUpdater()))
59+
60+
toSchema(config, queries, mutations)
61+
```
62+
63+
will generate
64+
65+
```graphql
66+
schema {
67+
query: Query
68+
mutation: Mutation
69+
}
70+
71+
type Query {
72+
widgetById(id: Int!): Widget
73+
74+
widgetByValue(vale: String!): Widget @deprecated(reason: "Use widgetById")
75+
}
76+
77+
type Mutation {
78+
saveWidget(value: String!): Widget!
79+
}
80+
81+
type Widget {
82+
id: Int!
83+
value: String!
84+
}
85+
```
86+
87+
## Documentation
88+
89+
There are more examples and documention in our [Uncyclo](https://github.com/ExpediaDotCom/graphql-kotlin/wiki) or you can view the [javadocs](https://www.javadoc.io/doc/com.expedia/graphql-kotlin) for all published versions.
90+
91+
If you have a question about something you can not find in our wiki or javadocs, feel free to [create an issue](https://github.com/ExpediaDotCom/graphql-kotlin/issues) and tag it with the question label.

0 commit comments

Comments
 (0)