Skip to content

Commit

Permalink
[Merge] Add Ratpack integration module
Browse files Browse the repository at this point in the history
  • Loading branch information
mariogarcia committed Jan 28, 2018
2 parents 1db8d82 + 89c43a3 commit c15a637
Show file tree
Hide file tree
Showing 109 changed files with 979 additions and 166 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# Change log
All notable changes to this project will be documented in this file.

## [0.2.0] - [2018-01-??]

## Added

- Documentation moved to its own Gradle module
- Ratpack GraphQL module
- Add docs of Ratpack module in the GQL user guide

## Changed

- GQL project estructure
- `gql` artifact is now `gql-core`
- Upgraded Gradle 3.5 => 4 due to Groovy compilation problems

## [0.1.9-alpha] - [2018-01-23]

## Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ In order to use `GQL` in your Groovy code you can find it in Bintray:

Then you can add the dependency to your project:

compile 'com.github.grooviter:gql:0.1.9-alpha'
compile 'com.github.grooviter:gql-core:0.2.0'

Current documentation is available at: http://grooviter.github.io/gql/
38 changes: 0 additions & 38 deletions build.gradle

This file was deleted.

86 changes: 86 additions & 0 deletions gql-core/gql-core.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
plugins {
id 'groovy'
id 'maven-publish'
}

apply plugin: 'com.jfrog.bintray'
apply from: "../gradle/groovydoc.gradle"

dependencies {
compile 'com.graphql-java:graphql-java:7.0'
compile "org.codehaus.groovy:groovy-all:$groovy"

testCompile "org.spockframework:spock-core:$spock"
testCompile 'junit:junit:4.12'
}

compileGroovy {
groovyOptions.configurationScript = new File(projectDir, folder_compiler)
}

sourceSets {
groovydoc {
resources {
srcDir folder_groovydoc
}
}
}

groovydoc {
link 'https://docs.oracle.com/javase/8/docs/api/', 'java'
link 'http://docs.groovy-lang.org/latest/html/api/', 'groovy', 'org.codehaus.groovy'
link 'http://graphql-java.github.io/graphql-java', 'graphql'
docTitle project.name

destinationDir = file("../gql-docs/build/site/api")
classpath = sourceSets.groovydoc.output + classpath
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

artifacts {
archives sourcesJar
}

publishing {
publications {
'gql-core'(MavenPublication) {
groupId "$releaseGroup"
artifactId 'gql-core'
version "$releaseVersion"

from components.java
artifact sourcesJar
}
}
}

bintray {
user = "$bintrayUser"
key = "$bintrayKey"

publish = true
publications = ['gql-core']

pkg {
repo = 'maven'
name = 'gql'
userOrg = 'grooviter'
desc = "$releaseDescription"
websiteUrl = 'http://grooviter.github.io/gql/'
issueTrackerUrl = 'https://github.com/grooviter/gql/issues'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/grooviter/gql.git'
labels = ['groovy', 'graphql', 'dsl', 'asts']

version {
name = "$releaseVersion"
desc = 'GQL Release'
released = new Date()
vcsTag = "$releaseVersion"
}
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
53 changes: 53 additions & 0 deletions gql-docs/gql-docs.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
plugins {
id 'org.asciidoctor.convert' version '1.5.3'
}

apply plugin: "org.ajoberstar.git-publish"

task generateDocumentation() {
dependsOn ':gql-core:groovydoc',':gql-ratpack:javadoc', asciidoctor

doLast {
copy {
from "src/docs/site"
into "$buildDir/site"
}
}
}

task setAuthentication() {
doLast {
System.setProperty('org.ajoberstar.grgit.auth.username', githubToken)
}
}

gitPublish {
repoUri = 'https://github.com/grooviter/gql.git'
branch = 'gh-pages'

contents {
from file('build/site')
}

commitMessage = "Released version ${releaseVersion}"
}

gitPublishPush {
dependsOn 'setAuthentication'
dependsOn 'generateDocumentation'
}



asciidoctor {
requires 'asciidoctor-diagram'

outputDir file("$buildDir/site/docs")
attributes 'endpoint-url': 'http://github.com/grooviter/gql',
'source-highlighter': 'coderay',
'releaseVersion': releaseVersion,
'imagesdir': './images',
'toc': 'left',
'icons': 'font',
'toclevels': 3
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ This is how a full GraphQL life cycle app looks like using **GQL**:

[source, groovy]
----
@Grab('com.github.grooviter:gql:0.1.5-alpha')
include::{baseDir}/../src/test/groovy/gql/DSLSpec.groovy[tags=grabExample, indent=0]
@Grab('com.github.grooviter:gql-core:0.2.0')
include::{baseDirFirstLevel}/gql-core/src/test/groovy/gql/DSLSpec.groovy[tags=grabExample, indent=0]
----

<1> Creates a type `GraphQLFilm`
Expand All @@ -28,7 +28,7 @@ You can add the following dependency to your Gradle project

[source, gradle, subs="attributes"]
----
compile com.github.grooviter:gql:{releaseVersion}'
compile 'com.github.grooviter:gql-core:{releaseVersion}'
----

The library is available at Bintray so all you have to do is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
:revnumber: {releaseVersion}
:numbered:
:imagesDir: images/
:baseDir: ../../../
:baseDir: ../../../../..
:baseDirFirstLevel: ../../../..
:stem:

:coreMain: {baseDir}/../../src/main/java
:testMain: {baseDir}/../../src/test/groovy
:testResources: {baseDir}/../../src/test/resources
:core: {baseDir}/gql-core
:coreMain: {core}/src/main/java
:testMain: {core}/src/test/groovy
:testResources: {core}/src/test/resources
:ratpack: {baseDir}/gql-ratpack

[quote]
GQL is a library created to make it easier to expose and consume
Expand All @@ -27,4 +30,6 @@ include::dsl.adoc[]

include::relay.adoc[]

include::ratpack.adoc[]

include::references.adoc[]
File renamed without changes.
90 changes: 90 additions & 0 deletions gql-docs/src/docs/asciidoc/ratpack.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
== Ratpack

Ratpack http://ratpack.io is a set of Java libraries for building
scalable HTTP applications.

You can use Ratpack to make a given GraphQL schema available through
HTTP.

=== Example

Here is a minimum Groovy working example of a GraphQL schema exposed
through HTTP thanks to Ratpack.

[source, groovy]
----
@Grapes([
@Grab('io.ratpack:ratpack-groovy:1.5.1'),
@Grab('org.slf4j:slf4j-simple:1.7.25'),
@Grab('com.github.grooviter:gql-ratpack:0.2.0')
])
import static ratpack.groovy.Groovy.ratpack
import gql.DSL
import gql.ratpack.GraphQLModule
import gql.ratpack.GraphQLHandler
import gql.ratpack.GraphiQLHandler
def schema = DSL.schema { // <1>
queries('Queries') {
field('hello') {
type GraphQLString
staticValue 'GraphQL and Groovy!'
}
}
}
ratpack {
bindings {
module GraphQLModule // <2>
bindInstance schema // <3>
}
handlers {
post('graphql', GraphQLHandler) // <4>
get('graphql/browser', GraphiQLHandler) // <5>
}
}
----
<1> Create the schema using `gql.DSL` api
<2> Add the `gql.ratpack.GraphQLModule` in order to provide sane defaults to handlers and GraphiQL configuration
<3> Add the schema to Ratpack's registry
<4> Register the `GraphQLHandler` to handle all GrahpQL request at `/graphql`
<5> Register the `GraphiQLHandler` to be able to expose GraphiQL client at `/graphql/browser`.

=== Configuration

If you would like to disable the GraphiQL client, you can always configure the
GraphQLModule setting the `activateGraphiQL` to `false`.

[source, groovy]
----
ratpack {
bindings {
module(GraphQLModule) { conf ->
conf.activateGraphiQL = false // <1>
}
//...
}
handlers {
//...
}
}
----

<1> Setting the `activateGraphiQL` to false will disable GraphiQL client

[sidebar]
.GraphiQL Client limitation
****
At the moment, the GraphQL module provides GraphiQL as an static html
page. However the resources (scripts/css) required to make it work
properly aren't loaded from Ratpack but retrieved online once it's
loaded by the browser.
That means the GraphiQL client will only work if the browser accessing
it has online access.
Of course, the idea for upcoming releases would be to serve everything
from the module so that it could be used under any circumstances.
****
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
boolean hasEnumConstants = classDoc.enumConstants()
def doGithubLink = { t ->
def linkName = classDoc.fullPathName
return "https://github.com/grooviter/gql/blob/master/src/main/groovy/${linkName}.groovy"
return "https://github.com/grooviter/${props.docTitle}/blob/master/src/main/groovy/${linkName}.groovy"
}
def dolink = { t, boolean b ->
boolean isArray = false
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit c15a637

Please sign in to comment.