Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

grooviter/gql

Repository files navigation

Description

GQL is a set of Groovy DSLs and AST transformations built on top of GraphQL-java that make it easier to build GraphQL schemas and execute GraphQL queries without losing type safety.

Gradle

In order to use GQL releases in your Groovy code add the maven central repository and if you'd like to evaluate some snapshots add the sonatype snapshots repository as well:

repositories {
mavenCentral()
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' } // FOR SNAPSHOTS
}

Once you've declared the maven repositories then add the dependencies to your project:

dependencies {
implementation 'com.github.grooviter:gql-core:VERSION'
implementation 'com.github.grooviter:gql-ratpack:VERSION'
}

Getting Started

You can directly execute the following example in your Groovy console:

@Grab('com.github.grooviter:gql-core:1.1.0')
import gql.DSL

def GraphQLFilm = DSL.type('Film') {
field 'title', GraphQLString
field 'year', GraphQLInt
}

def schema = DSL.schema {
queries {
field('lastFilm') {
type GraphQLFilm
staticValue(title: 'No Time to die', year: 2021)
}
}
}

def query = """
{
lastFilm {
year
title
}
}
"""

def result = DSL.newExecutor(schema).execute(query)

assert result.data.lastFilm.year == 2021
assert result.data.lastFilm.title == 'No time to die'

Documentation

Current documentation is available at: http://grooviter.github.io/gql/

About

Groovy GraphQL library

Topics

Resources

Readme

License

Apache-2.0 license

Stars

Watchers

Forks

Packages

Contributors