diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml deleted file mode 100644 index 1956a4f2..00000000 --- a/.github/workflows/publish.yml +++ /dev/null @@ -1,30 +0,0 @@ -# This workflow will build a Java project with Gradle -# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-gradle - -name: Publish - -on: - workflow_dispatch: - branches: [ master ] - -jobs: - publish: - runs-on: ubuntu-latest - environment: prod - steps: - - uses: actions/checkout@v2 - - name: Set up JDK 8 - uses: actions/setup-java@v2 - with: - java-version: '8' - distribution: 'zulu' - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - name: Build with Gradle - run: ./gradlew build - - name: Publish with Gradle - run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository - env: - MAVEN_CENTRAL_USER: ${{ secrets.MAVEN_CENTRAL_USER }} - MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} - MAVEN_CENTRAL_PGP_KEY: ${{ secrets.MAVEN_CENTRAL_PGP_KEY }} diff --git a/.github/workflows/build.yml b/.github/workflows/test.yml similarity index 82% rename from .github/workflows/build.yml rename to .github/workflows/test.yml index ec380e3f..141f01d6 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/test.yml @@ -3,22 +3,22 @@ name: Build -on: [push, pull_request] +on: push jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Set up JDK 8 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '8' - distribution: 'zulu' + java-version: '17' + distribution: 'temurin' - name: Grant execute permission for gradlew run: chmod +x gradlew - name: Build with Gradle - run: ./gradlew build + run: ./gradlew test - name: Publish Test Report uses: mikepenz/action-junit-report@v2 if: always() # always run even if the previous step fails diff --git a/.java-version b/.java-version new file mode 100644 index 00000000..98d9bcb7 --- /dev/null +++ b/.java-version @@ -0,0 +1 @@ +17 diff --git a/README.md b/README.md index bb5d082c..7cc5c0e9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,13 @@ syntax for GraphQL schema definition. If you would like to use a tool that creates a graphql spring boot server using graphql-java-annotations, you can view the [graphql-spring-annotations](https://github.com/yarinvak/graphql-spring-annotations) library. +## Forked to ... + +- Upgrade graphql java (20.3) +- Update build tools and dependencies in general +- Fix `id` to allow to be of any type, since this is the GraphQL specsq + +Yet this package is not published anywhere. Let us know if that is interesting to anybody. ## Table Of Contents - [Getting Started](#getting-started) @@ -37,7 +44,7 @@ If you would like to use a tool that creates a graphql spring boot server using ```groovy dependencies { - compile "io.github.graphql-java:graphql-java-annotations:9.1" + compile "io.github.graphql-java:graphql-java-annotations:20.3.0-kw1" } ``` @@ -47,7 +54,7 @@ dependencies { io.github.graphql-java graphql-java-annotations - 9.1 + 20.3.0-kw1 ``` diff --git a/README.release.md b/README.release.md new file mode 100644 index 00000000..3a0c8952 --- /dev/null +++ b/README.release.md @@ -0,0 +1,9 @@ +## Release + +```bash +# adjust the version +vim gradle.properties +./gradlew publish +git tag $youversion +git push --tags +```` diff --git a/build.gradle b/build.gradle index 537f2edc..b5b6d9e2 100644 --- a/build.gradle +++ b/build.gradle @@ -5,41 +5,28 @@ buildscript { mavenCentral() } dependencies { - classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:5.1.2' - classpath "org.jfrog.buildinfo:build-info-extractor-gradle:latest.release" + classpath 'biz.aQute.bnd:biz.aQute.bnd.gradle:6.4.0' } } plugins { - id 'net.researchgate.release' version '2.8.1' - id 'com.github.hierynomus.license' version '0.15.0' + id 'java' + id 'idea' id 'maven-publish' - id 'signing' - id "io.github.gradle-nexus.publish-plugin" version "1.0.0" + id 'com.github.hierynomus.license' version '0.16.1' + id "biz.aQute.bnd.builder" version "6.4.0" } -apply plugin: 'java' -apply plugin: 'idea' -apply plugin: 'biz.aQute.bnd.builder' -apply plugin: 'maven-publish' - - // custom tasks for creating source/javadoc jars task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' + archiveClassifier = 'sources' from sourceSets.main.allSource } task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' + archiveClassifier = 'javadoc' from javadoc.destinationDir } -release { - tagTemplate = 'v${version}' - failOnPublishNeeded = false - failOnCommitNeeded = false -} - repositories { mavenCentral() } @@ -53,20 +40,23 @@ gradle.projectsEvaluated { } dependencies { - compile 'javax.validation:validation-api:1.1.0.Final' - compile 'com.graphql-java:graphql-java:17.4' - compile 'com.graphql-java:graphql-java-extended-scalars:17.0' - + implementation 'javax.validation:validation-api:2.0.1.Final' + // @see https://mvnrepository.com/artifact/com.graphql-java/graphql-java + implementation 'com.graphql-java:graphql-java:21.3' + // @see https://mvnrepository.com/artifact/com.graphql-java/graphql-java-extended-scalars + implementation 'com.graphql-java:graphql-java-extended-scalars:21.0' + implementation 'javax.xml.bind:jaxb-api:2.3.1' // OSGi - compileOnly 'org.osgi:org.osgi.core:6.0.0' - compileOnly 'org.osgi:org.osgi.service.cm:1.5.0' - compileOnly 'org.osgi:org.osgi.service.component:1.3.0' - compileOnly 'biz.aQute.bnd:biz.aQute.bndlib:3.2.0' - - testCompile 'org.testng:testng:6.9.10' - testCompile 'org.hamcrest:hamcrest-all:1.3' - testCompile 'org.mockito:mockito-core:2.+' + compileOnly 'org.osgi:osgi.core:8.0.0' + compileOnly 'org.osgi:org.osgi.service.cm:1.6.0' + compileOnly 'org.osgi:org.osgi.service.component:1.5.1' + compileOnly 'biz.aQute.bnd:biz.aQute.bndlib:3.5.0' + + testImplementation 'org.testng:testng:7.8.0' + // @see https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all + testImplementation 'org.hamcrest:hamcrest-all:1.3' + testImplementation 'org.mockito:mockito-core:5.6.0' } test.useTestNG() @@ -80,20 +70,21 @@ publishing { version project.version artifact sourcesJar - artifact javadocJar + // FIXME: does no longer work (most probably gradle 8 related) +// artifact javadocJar pom.withXml { asNode().children().last() + { resolveStrategy = Closure.DELEGATE_FIRST name 'graphql-java-annotations' description 'Annotations-based syntax for GraphQL schema definition' - url 'https://github.com/graphql-java/graphql-java-annotations' - inceptionYear '2016' + url 'https://github.com/KontextWork/graphql-java-annotations' + inceptionYear '2022' scm { - url 'https://github.com/graphql-java/graphql-java-annotations' - connection 'scm:https://yrashk@github.com/graphql-java/graphql-java-annotations.git' - developerConnection 'scm:git://github.com/graphql-java/graphql-java-annotations.git' + url 'https://github.com/KontextWork/graphql-java-annotations' + connection 'scm:https://github.com/KontextWork/graphql-java-annotations.git' + developerConnection 'scm:git://github.com/KontextWork/graphql-java-annotations.git' } licenses { @@ -106,32 +97,14 @@ publishing { developers { developer { - id 'yrashk' - name 'Yurii Rashkovskii' - email 'yrashk@gmail.com' - } - developer { - id 'apottere' - name 'Andrew Potter' - email 'Andrew.Potter@coxautoinc.com' - } - developer { - id 'bbakerman' - name 'Brad Baker' - email 'bbakerman@gmail.com' - } - developer { - id 'yarinvak' - name 'Yarin Vaknin' - email 'yarinvak@gmail.com' - } - developer { - id 'guy120494' - name 'Guy Smorodinsky' + id 'tm' + name 'Thomas M.' + email 'tm@donotbugme.com' } developer { - id 'osher-sade' - name 'Osher Sade' + id 'em' + name 'Eugen Mayer' + email 'em@donotbugme.com' } } } @@ -140,29 +113,24 @@ publishing { } } -afterReleaseBuild.dependsOn nexusPublishing -nexusPublishing { +publishing { repositories { - sonatype { - username = System.getenv("MAVEN_CENTRAL_USER") - password = System.getenv("MAVEN_CENTRAL_PASSWORD") + maven { + def releasesRepoUrl = "https://nexus.kw.kontextwork.com/repository/kw-maven-release" + def snapshotsRepoUrl = "https://nexus.kw.kontextwork.com/repository/kw-maven-snapshots" + url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl + if(project.hasProperty("ourNexusAuthorUser")) { + credentials(PasswordCredentials) { + username "$ourNexusAuthorUser" + password "$ourNexusAuthorPassword" + } + } } } } -// to publish to local maven repo skip signing: ./gradlew publishToMavenLocal -x signGraphqlJavaPublication -signing { - def signingKey = System.getenv("MAVEN_CENTRAL_PGP_KEY") - useInMemoryPgpKeys(signingKey, "") - sign publishing.publications -} - task bundle(type: Bundle) { from sourceSets.main.output bndfile = file('bundle.bnd') } - -wrapper { - gradleVersion = '6.5.1' -} diff --git a/gradle.properties b/gradle.properties index 966851e1..dc07fdc7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,4 +5,4 @@ org.gradle.daemon=true org.gradle.parallel=true org.gradle.jvmargs=-Dfile.encoding=UTF-8 -version = 9.1 +version = 21.3.0-kw1 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index f3d88b1c..7f93135c 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index bb8b2fc2..3fa8f862 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,7 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 2fe81a7d..1aa94a42 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -17,78 +17,111 @@ # ############################################################################## -## -## Gradle start up script for UN*X -## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,87 +130,120 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat index 9618d8d9..93e3f59f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -14,7 +14,7 @@ @rem limitations under the License. @rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem @rem Gradle startup script for Windows @@ -25,10 +25,14 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -51,7 +55,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -61,38 +65,26 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd +if %ERRORLEVEL% equ 0 goto mainEnd :fail rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java index 0082f5f5..f17810af 100644 --- a/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java +++ b/src/main/java/graphql/annotations/processor/retrievers/fieldBuilders/DirectivesBuilder.java @@ -14,6 +14,14 @@ */ package graphql.annotations.processor.retrievers.fieldBuilders; +import java.lang.annotation.Annotation; +import java.lang.reflect.AnnotatedElement; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + import graphql.annotations.annotationTypes.directives.activation.GraphQLDirectives; import graphql.annotations.processor.ProcessingElementsContainer; import graphql.annotations.processor.exceptions.GraphQLAnnotationsException; @@ -23,14 +31,6 @@ import graphql.schema.GraphQLScalarType; import graphql.schema.GraphQLType; -import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.stream.Collectors; - import static graphql.schema.GraphQLDirective.newDirective; @@ -133,13 +133,15 @@ private void transformArgument(Annotation annotation, GraphQLDirective.Builder d methods[finalI].setAccessible(true); Object argumentValue = methods[finalI].invoke(annotation); Object value; - if (graphQLArgument.getType() instanceof GraphQLScalarType) { + if ( graphQLArgument.getType() instanceof GraphQLScalarType ) + { value = ((GraphQLScalarType) graphQLArgument.getType()).getCoercing().parseValue(argumentValue); } - else{ + else + { value = argumentValue; } - builder.value(value); + builder.value( value ); } catch (Exception e) { throw new GraphQLAnnotationsException(COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE, e); } @@ -160,7 +162,7 @@ private void transformArgument(String[] argumentValues, GraphQLDirective.Builder try { Object value = ((GraphQLScalarType) graphQLArgument.getType()).getCoercing().parseValue(argumentValue); - builder.value(value); + builder.value( value ); } catch (Exception e) { throw new GraphQLAnnotationsException(COULD_NOT_PARSE_ARGUMENT_VALUE_TO_ARGUMENT_TYPE, e); } diff --git a/src/test/java/graphql/annotations/GraphQLDataFetcherTest.java b/src/test/java/graphql/annotations/GraphQLDataFetcherTest.java index 233a58df..3b172424 100644 --- a/src/test/java/graphql/annotations/GraphQLDataFetcherTest.java +++ b/src/test/java/graphql/annotations/GraphQLDataFetcherTest.java @@ -22,12 +22,14 @@ import graphql.annotations.processor.GraphQLAnnotations; import graphql.schema.DataFetcher; import graphql.schema.DataFetchingEnvironment; +import graphql.schema.GraphQLFieldDefinition; import graphql.schema.GraphQLSchema; import graphql.schema.PropertyDataFetcher; import org.testng.annotations.BeforeMethod; import org.testng.annotations.Test; import java.util.HashMap; +import java.util.function.Supplier; import static graphql.annotations.AnnotationsSchemaCreator.newAnnotationsSchema; import static org.testng.Assert.*; @@ -161,8 +163,10 @@ public SampleMultiArgDataFetcher(String target, String flip) { } @Override - public Object get(DataFetchingEnvironment environment) { - final Object result = super.get(environment); + public Object get( final GraphQLFieldDefinition fieldDefinition, final Object source, final Supplier supplier ) + throws Exception + { + final Object result = super.get( fieldDefinition, source, supplier ); if (flip) { return !(Boolean) result; } else { diff --git a/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java b/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java index f3117194..4894b772 100644 --- a/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java +++ b/src/test/java/graphql/annotations/GraphQLDirectivesViaClassDefinitionTest.java @@ -225,7 +225,7 @@ public void queryNameWithFalse_directivesProvidedToRegistry_wiringIsActivated() this.graphQLAnnotations.getContainer().getDirectiveRegistry().put(upperCase.getName(), new DirectiveAndWiring(upperCase, UpperWiring.class)); GraphQLObjectType object = this.graphQLAnnotations.object(Query.class); GraphQLCodeRegistry codeRegistry = graphQLAnnotations.getContainer().getCodeRegistryBuilder().build(); - GraphQLSchema schema = newSchema().query(object).codeRegistry(codeRegistry).build(); + GraphQLSchema schema = newSchema().query(object).additionalDirective(upperCase).codeRegistry(codeRegistry).build(); ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("query { nameWithFalse }"); assertTrue(result.getErrors().isEmpty()); diff --git a/src/test/java/graphql/annotations/GraphQLExtensionsTest.java b/src/test/java/graphql/annotations/GraphQLExtensionsTest.java index 6f2f663f..db7e5d0e 100644 --- a/src/test/java/graphql/annotations/GraphQLExtensionsTest.java +++ b/src/test/java/graphql/annotations/GraphQLExtensionsTest.java @@ -117,7 +117,8 @@ public void fields() { public void values() { GraphQLSchema schema = newAnnotationsSchema().query(TestObject.class).typeExtension(TestObjectExtension.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{field field2 field3 field4 field5}", new GraphQLExtensionsTest.TestObject()); + ExecutionResult result = GraphQL.newGraphQL( schema ).build().execute( + GraphQLHelper.createExecutionInput( "{field field2 field3 field4 field5}", new GraphQLExtensionsTest.TestObject() ) ); Map data = result.getData(); assertEquals(data.get("field"), "test"); assertEquals(data.get("field2"), "test test2"); diff --git a/src/test/java/graphql/annotations/GraphQLFragmentTest.java b/src/test/java/graphql/annotations/GraphQLFragmentTest.java index df8c901e..b127bff4 100644 --- a/src/test/java/graphql/annotations/GraphQLFragmentTest.java +++ b/src/test/java/graphql/annotations/GraphQLFragmentTest.java @@ -65,7 +65,7 @@ public void testInterfaceInlineFragment() throws Exception { GraphQL graphQL2 = GraphQL.newGraphQL(schema).build(); // When - ExecutionResult graphQLResult = graphQL2.execute("{getItems { ... on MyObject {getA, getMy {getB}} ... on MyObject2 {getA, getB} }}", new RootObject()); + ExecutionResult graphQLResult = graphQL2.execute(GraphQLHelper.createExecutionInput("{getItems { ... on MyObject {getA, getMy {getB}} ... on MyObject2 {getA, getB} }}", new RootObject())); Set resultMap = ((Map) graphQLResult.getData()).entrySet(); // Then diff --git a/src/test/java/graphql/annotations/GraphQLHelper.java b/src/test/java/graphql/annotations/GraphQLHelper.java new file mode 100644 index 00000000..ededb29b --- /dev/null +++ b/src/test/java/graphql/annotations/GraphQLHelper.java @@ -0,0 +1,37 @@ +/** + * Copyright 2016 Yurii Rashkovskii + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + */ +package graphql.annotations; + +import java.util.Map; + +import graphql.ExecutionInput; + +public class GraphQLHelper +{ + public static ExecutionInput createExecutionInput( String query, Object context, Map variables ) + { + ExecutionInput.Builder builder = ExecutionInput.newExecutionInput().query( query ).root( context ); + if ( variables != null ) + { + builder.variables( variables ); + } + return builder.build(); + } + + public static ExecutionInput createExecutionInput( String query, Object context ) + { + return createExecutionInput( query, context, null ); + } +} diff --git a/src/test/java/graphql/annotations/GraphQLInputTest.java b/src/test/java/graphql/annotations/GraphQLInputTest.java index 3561a7b0..3a129208 100644 --- a/src/test/java/graphql/annotations/GraphQLInputTest.java +++ b/src/test/java/graphql/annotations/GraphQLInputTest.java @@ -186,7 +186,7 @@ public void query() { .additionalType(TestObject.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ object { value(input:{key:\"test\"}) } }", new Query()); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:{key:\"test\"}) } }", new Query())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map>) result.getData()).get("object").get("value"), "testa"); } @@ -196,7 +196,7 @@ public void queryMultipleDefinitions() { GraphQLSchema schema = newAnnotationsSchema().query(QueryMultipleDefinitions.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ something(code: {firstField:\"a\",secondField:\"b\"}) somethingElse(code: {firstField:\"c\",secondField:\"d\"}) }", new QueryMultipleDefinitions()); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ something(code: {firstField:\"a\",secondField:\"b\"}) somethingElse(code: {firstField:\"c\",secondField:\"d\"}) }", new QueryMultipleDefinitions())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("something"), "ab"); assertEquals(((Map) result.getData()).get("somethingElse"), "cd"); @@ -207,11 +207,11 @@ public void queryWithRecursion() { GraphQLSchema schema = newAnnotationsSchema().query(QueryRecursion.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ object { value(input:{key:\"test\"}) } }", new QueryRecursion()); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:{key:\"test\"}) } }", new QueryRecursion())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map>) result.getData()).get("object").get("value"), "testa"); - result = graphQL.execute("{ object { value(input:{rec:{key:\"test\"}}) } }", new QueryRecursion()); + result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:{rec:{key:\"test\"}}) } }", new QueryRecursion())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map>) result.getData()).get("object").get("value"), "rectesta"); } @@ -221,7 +221,7 @@ public void queryWithList() { GraphQLSchema schema = newAnnotationsSchema().query(QueryList.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ object { value(input:[[[{key:\"test\", complex:[{subKey:\"subtest\"},{subKey:\"subtest2\"}]}]]]) } }", new QueryList()); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ object { value(input:[[[{key:\"test\", complex:[{subKey:\"subtest\"},{subKey:\"subtest2\"}]}]]]) } }", new QueryList())); assertEquals(((Map>) result.getData()).get("object").get("value"), "test-subtest"); } @@ -230,7 +230,7 @@ public void queryWithInterface() { GraphQLSchema schema = newAnnotationsSchema().query(QueryIface.class).additionalType(TestObject.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ iface { value(input:{key:\"test\"}) } }", new QueryIface()); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ iface { value(input:{key:\"test\"}) } }", new QueryIface())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map>) result.getData()).get("iface").get("value"), "testa"); } diff --git a/src/test/java/graphql/annotations/GraphQLInterfaceTest.java b/src/test/java/graphql/annotations/GraphQLInterfaceTest.java index 00c0ae57..4dba806d 100644 --- a/src/test/java/graphql/annotations/GraphQLInterfaceTest.java +++ b/src/test/java/graphql/annotations/GraphQLInterfaceTest.java @@ -170,7 +170,7 @@ public void queryUnion() { GraphQLSchema schema = newAnnotationsSchema().query(UnionQuery.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ union { ... on TestObject1 { value } } }", new UnionQuery(new TestObject1())); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ union { ... on TestObject1 { value } } }", new UnionQuery(new TestObject1()))); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map>) result.getData()).get("union").get("value"), "a"); } diff --git a/src/test/java/graphql/annotations/GraphQLObjectTest.java b/src/test/java/graphql/annotations/GraphQLObjectTest.java index 246d3473..0f6f84de 100644 --- a/src/test/java/graphql/annotations/GraphQLObjectTest.java +++ b/src/test/java/graphql/annotations/GraphQLObjectTest.java @@ -333,10 +333,10 @@ public void methodInheritance() { GraphQLSchema schema = newAnnotationsSchema().query(TestObject.class).build(); GraphQLSchema schemaInherited = newAnnotationsSchema().query(TestObjectInherited.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{field0}", new TestObject()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{field0}", new TestObject())); assertEquals(((Map) result.getData()).get("field0"), "test"); GraphQL graphQL = GraphQL.newGraphQL(schemaInherited).build(); - result = graphQL.execute("{field1}", new TestObjectInherited()); + result = graphQL.execute(GraphQLHelper.createExecutionInput("{field1}", new TestObjectInherited())); assertEquals(((Map) result.getData()).get("field1"), "inherited"); } @@ -369,7 +369,7 @@ public String id() { public void methodInheritanceWithGenerics() { GraphQLSchema schema = newAnnotationsSchema().query(TestObjectBridgMethod.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{id}", new TestObjectBridgMethod()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{id}", new TestObjectBridgMethod())); assertEquals(((Map) result.getData()).get("id"), "1"); } @@ -517,7 +517,7 @@ public String someField() { public void dataFetcher() { GraphQLSchema schema = newAnnotationsSchema().query(TestDataFetcher.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{field someField}", new TestObject()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{field someField}", new TestObject())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("field"), "test"); assertEquals(((Map) result.getData()).get("someField"), "test"); @@ -527,15 +527,15 @@ public void dataFetcher() { public void query() { GraphQLSchema schema = newAnnotationsSchema().query(TestObject.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{field0}", new TestObject()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{field0}", new TestObject())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("field0"), "test"); - result = GraphQL.newGraphQL(schema).build().execute("{fieldWithArgs(a: \"test\", b: \"passed\")}", new TestObject()); + result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{fieldWithArgs(a: \"test\", b: \"passed\")}", new TestObject())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("fieldWithArgs"), "passed"); - result = GraphQL.newGraphQL(schema).build().execute("{fieldWithArgsAndEnvironment(a: \"test\", b: \"passed\")}", new TestObject()); + result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{fieldWithArgsAndEnvironment(a: \"test\", b: \"passed\")}", new TestObject())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("fieldWithArgsAndEnvironment"), "test"); @@ -545,7 +545,7 @@ public void query() { public void queryField() { GraphQLSchema schema = newAnnotationsSchema().query(TestField.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{field1}", new TestField()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{field1}", new TestField())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("field1"), "test"); } @@ -554,7 +554,7 @@ public void queryField() { public void queryPrivateField() { GraphQLSchema schema = newAnnotationsSchema().query(PrivateTestField.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{field1, field2, booleanField}", new PrivateTestField()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{field1, field2, booleanField}", new PrivateTestField())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("field1"), "test"); assertEquals(((Map) result.getData()).get("field2"), "test"); @@ -566,7 +566,7 @@ public void queryPrivateField() { public void defaultArg() { GraphQLSchema schema = newAnnotationsSchema().query(TestObject.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{fieldWithArgs(a: \"test\")}", new TestObject()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{fieldWithArgs(a: \"test\")}", new TestObject())); assertTrue(result.getErrors().isEmpty()); assertEquals(((Map) result.getData()).get("fieldWithArgs"), "default"); } @@ -599,18 +599,18 @@ public void recursiveTypes() { class2.value = "hello"; class1.value = "bye"; - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{ class2 { value } }", class1); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput( "{ class2 { value } }", class1)); assertTrue(result.getErrors().isEmpty()); Map data = (Map) result.getData(); assertEquals(((Map) data.get("class2")).get("value"), "hello"); - result = GraphQL.newGraphQL(schema).build().execute("{ class2 { class1 { value } } }", class1); + result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{ class2 { class1 { value } } }", class1)); assertTrue(result.getErrors().isEmpty()); data = (Map) result.getData(); Map k1 = (Map) ((Map) data.get("class2")).get("class1"); assertEquals(k1.get("value"), "bye"); - result = GraphQL.newGraphQL(schema).build().execute("{ class2 { class1 { class2 { value } } } }", class1); + result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{ class2 { class1 { class2 { value } } } }", class1)); assertTrue(result.getErrors().isEmpty()); } @@ -698,7 +698,8 @@ public void inputObjectArgument() { assertEquals(argument.getName(), "arg"); GraphQLSchema schema = newAnnotationsSchema().query(TestObjectInput.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{ test( other:0,arg: { a:\"ok\", b:2 }) }", new TestObjectInput()); + ExecutionResult result = GraphQL.newGraphQL( schema ).build().execute( + GraphQLHelper.createExecutionInput( "{ test( other:0,arg: { a:\"ok\", b:2 }) }", new TestObjectInput() ) ); assertTrue(result.getErrors().isEmpty()); Map v = (Map) result.getData(); assertEquals(v.get("test"), "ok"); @@ -712,7 +713,7 @@ public void complexInputObjectArgument() { assertEquals(argument.getName(), "arg"); GraphQLSchema schema = newAnnotationsSchema().query(TestObjectInput.class).build(); - ExecutionResult result = GraphQL.newGraphQL(schema).build().execute("{ test2(arg: {inputs:[{ a:\"ok\", b:2 }]}, other:0) }", new TestObjectInput()); + ExecutionResult result = GraphQL.newGraphQL(schema).build().execute(GraphQLHelper.createExecutionInput("{ test2(arg: {inputs:[{ a:\"ok\", b:2 }]}, other:0) }", new TestObjectInput())); assertTrue(result.getErrors().isEmpty()); Map v = result.getData(); assertEquals(v.get("test2"), "ok"); @@ -795,7 +796,7 @@ public void queryOptional() { GraphQLSchema schema = newSchema().query(object).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{empty, nonempty}", new OptionalTest()); + ExecutionResult result = graphQL.execute( GraphQLHelper.createExecutionInput( "{empty, nonempty}", new OptionalTest() ) ); assertTrue(result.getErrors().isEmpty()); Map v = (Map) result.getData(); assertNull(v.get("empty")); @@ -818,7 +819,7 @@ public void optionalInput() { GraphQLSchema schema = newSchema().query(object).mutation(mutation).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("mutation {test(input: {empty: \"test\"}) { empty nonempty } }", new OptionalTest()); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput( "mutation {test(input: {empty: \"test\"}) { empty nonempty } }", new OptionalTest() )); assertTrue(result.getErrors().isEmpty()); Map v = (Map) ((Map) result.getData()).get("test"); assertEquals(v.get("empty"), "test"); @@ -850,7 +851,7 @@ public void queryEnum() { GraphQLSchema schema = newSchema().query(object).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{e}", new EnumTest(EnumTest.E.B)); + ExecutionResult result = graphQL.execute( GraphQLHelper.createExecutionInput( "{e}", new EnumTest( EnumTest.E.B ) ) ); assertTrue(result.getErrors().isEmpty()); Map v = (Map) result.getData(); assertEquals(v.get("e"), "B"); diff --git a/src/test/java/graphql/annotations/RelayTest.java b/src/test/java/graphql/annotations/RelayTest.java index 85874ab8..0d7a2057 100644 --- a/src/test/java/graphql/annotations/RelayTest.java +++ b/src/test/java/graphql/annotations/RelayTest.java @@ -133,7 +133,9 @@ public void noArgMutation() { GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build(); - ExecutionResult result = graphQL.execute("mutation { doSomething(input: {clientMutationId: \"1\"}) { getI clientMutationId } }", new TestObject()); + ExecutionResult result = graphQL.execute( + GraphQLHelper.createExecutionInput( "mutation { doSomething(input: {clientMutationId: \"1\"}) { getI clientMutationId } }", + new TestObject() ) ); assertEquals(result.getErrors().size(), 0); @@ -155,7 +157,9 @@ public void interfaceReturningMutation() { GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build(); - ExecutionResult result = graphQL.execute("mutation { doSomethingI(input: {clientMutationId: \"1\"}) { getI clientMutationId } }", new TestObject()); + ExecutionResult result = graphQL.execute( + GraphQLHelper.createExecutionInput( "mutation { doSomethingI(input: {clientMutationId: \"1\"}) { getI clientMutationId } }", + new TestObject() ) ); assertEquals(result.getErrors().size(), 0); @@ -194,7 +198,8 @@ public void argMutation() { GraphQL graphQL = GraphQL.newGraphQL(schema).queryExecutionStrategy(new EnhancedExecutionStrategy()).build(); - ExecutionResult result = graphQL.execute("mutation { doSomethingElse(input: {a: 0, b: 1, clientMutationId: \"1\"}) { getI clientMutationId } }", new TestObject()); + ExecutionResult result = graphQL.execute( GraphQLHelper.createExecutionInput( + "mutation { doSomethingElse(input: {a: 0, b: 1, clientMutationId: \"1\"}) { getI clientMutationId } }", new TestObject() ) ); assertEquals(result.getErrors().size(), 0); @@ -237,7 +242,10 @@ public void argVariableMutation() { inputVariables.put("b", 1); inputVariables.put("clientMutationId", "1"); variables.put("input", inputVariables); - ExecutionResult result = graphQL.execute("mutation VariableMutation($input:DoSomethingElseInput!) { doSomethingElse(input: $input) { getI clientMutationId } }", new TestObject(), variables); + + ExecutionResult result = graphQL.execute( GraphQLHelper.createExecutionInput( + "mutation VariableMutation($input:DoSomethingElseInput!) { doSomethingElse(input: $input) { getI clientMutationId } }", + new TestObject(), variables ) ); assertEquals(result.getErrors().size(), 0); diff --git a/src/test/java/graphql/annotations/connection/GraphQLConnectionTest.java b/src/test/java/graphql/annotations/connection/GraphQLConnectionTest.java index ec1ebd57..fe6ce274 100644 --- a/src/test/java/graphql/annotations/connection/GraphQLConnectionTest.java +++ b/src/test/java/graphql/annotations/connection/GraphQLConnectionTest.java @@ -14,6 +14,7 @@ import graphql.ExecutionResult; import graphql.GraphQL; +import graphql.annotations.GraphQLHelper; import graphql.annotations.annotationTypes.GraphQLField; import graphql.annotations.annotationTypes.GraphQLName; import graphql.annotations.annotationTypes.GraphQLNonNull; @@ -135,8 +136,9 @@ public void fieldList() { GraphQLSchema schema = newSchema().query(object).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ objs(first: 1) { edges { cursor node { id, val } } } }", - new TestListField(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world")))); + ExecutionResult result = graphQL.execute( + GraphQLHelper.createExecutionInput( "{ objs(first: 1) { edges { cursor node { id, val } } } }", + new TestListField(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"))))); } @Test @@ -144,8 +146,8 @@ public void methodList() { GraphQLSchema schema = newAnnotationsSchema().query(TestConnections.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getObjs(first: 1) { edges { cursor node { id, val } } } }", - new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world")))); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getObjs(first: 1) { edges { cursor node { id, val } } } }", + new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"))))); assertTrue(result.getErrors().isEmpty()); @@ -186,8 +188,8 @@ public void methodStream() { GraphQLSchema schema = newAnnotationsSchema().query(TestConnections.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getObjStream(first: 1) { edges { cursor node { id, val } } } }", - new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world")))); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getObjStream(first: 1) { edges { cursor node { id, val } } } }", + new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"))))); assertTrue(result.getErrors().isEmpty()); @@ -199,8 +201,8 @@ public void methodNonNull() { GraphQLSchema schema = newAnnotationsSchema().query(TestConnections.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getNonNullObjs(first: 1) { edges { cursor node { id, val } } } }", - new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world")))); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getNonNullObjs(first: 1) { edges { cursor node { id, val } } } }", + new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"))))); assertTrue(result.getErrors().isEmpty()); @@ -212,8 +214,8 @@ public void methodDoubleNonNull() { GraphQLSchema schema = newAnnotationsSchema().query(TestConnections.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getDoubleNonNullObjs(first: 1) { edges { cursor node { id, val } } } }", - new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world")))); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getDoubleNonNullObjs(first: 1) { edges { cursor node { id, val } } } }", + new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"))))); assertTrue(result.getErrors().isEmpty()); @@ -225,8 +227,8 @@ public void methodNull() { GraphQLSchema schema = newAnnotationsSchema().query(TestConnections.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getNullObj(first: 1) { edges { cursor node { id, val } } } }", - new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world")))); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getNullObj(first: 1) { edges { cursor node { id, val } } } }", + new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"))))); assertTrue(result.getErrors().isEmpty()); @@ -240,8 +242,8 @@ public void emptyListData() { GraphQLSchema schema = newAnnotationsSchema().query(TestConnections.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getObjStreamWithParam(first: 1, filter:\"hel\") { edges { cursor node { id, val } } } }", - new TestConnections(emptyList())); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getObjStreamWithParam(first: 1, filter:\"hel\") { edges { cursor node { id, val } } } }", + new TestConnections(emptyList()))); assertTrue(result.getErrors().isEmpty()); Map>>>> data = result.getData(); @@ -255,8 +257,8 @@ public void methodListWithParam() { GraphQLSchema schema = newAnnotationsSchema().query(TestConnections.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getObjStreamWithParam(first: 2, filter:\"hel\") { edges { cursor node { id, val } } } }", - new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"), new Obj("4", "hello world"), new Obj("5", "hello again")))); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getObjStreamWithParam(first: 2, filter:\"hel\") { edges { cursor node { id, val } } } }", + new TestConnections(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"), new Obj("4", "hello world"), new Obj("5", "hello again"))))); assertTrue(result.getErrors().isEmpty()); @@ -306,8 +308,8 @@ public void customConnection() { GraphQLSchema schema = newAnnotationsSchema().query(TestCustomConnection.class).build(); GraphQL graphQL = GraphQL.newGraphQL(schema).build(); - ExecutionResult result = graphQL.execute("{ getObjs(first: 1) { edges { cursor node { id, val } } } }", - new TestCustomConnection(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world")))); + ExecutionResult result = graphQL.execute(GraphQLHelper.createExecutionInput("{ getObjs(first: 1) { edges { cursor node { id, val } } } }", + new TestCustomConnection(Arrays.asList(new Obj("1", "test"), new Obj("2", "hello"), new Obj("3", "world"))))); assertTrue(result.getErrors().isEmpty()); Map data = result.getData(); diff --git a/src/test/java/graphql/annotations/directives/DirectiveSchemaVisitorTest.java b/src/test/java/graphql/annotations/directives/DirectiveSchemaVisitorTest.java index 0c5fd39f..8f97c722 100644 --- a/src/test/java/graphql/annotations/directives/DirectiveSchemaVisitorTest.java +++ b/src/test/java/graphql/annotations/directives/DirectiveSchemaVisitorTest.java @@ -77,8 +77,8 @@ public void visitGraphQLArgument_noDirectives_returnsContinue() { TraversalControl traversalControl = directiveSchemaVisitor.visitGraphQLArgument(argument, context); // Assert - verifyZeroInteractions(wiringMock); - verifyZeroInteractions(transformerUtilWrapper); + verifyNoMoreInteractions(wiringMock); + verifyNoMoreInteractions(transformerUtilWrapper); assertEquals(traversalControl, TraversalControl.CONTINUE); } @@ -98,7 +98,7 @@ public void visitGraphQLArgument_noWiringFunction_changedToSameNode() { directiveSchemaVisitor.visitGraphQLArgument(argument, context); // Assert - verifyZeroInteractions(wiringMock); + verifyNoMoreInteractions(wiringMock); verify(transformerUtilWrapper).changeNode(eq(context), eq(argument)); } @@ -133,8 +133,8 @@ public void visitGraphQLFieldDefinition_noDirectives_returnsContinue() { TraversalControl traversalControl = directiveSchemaVisitor.visitGraphQLFieldDefinition(type, context); // Assert - verifyZeroInteractions(wiringMock); - verifyZeroInteractions(transformerUtilWrapper); + verifyNoMoreInteractions(wiringMock); + verifyNoMoreInteractions(transformerUtilWrapper); assertEquals(traversalControl, TraversalControl.CONTINUE); } @@ -154,7 +154,7 @@ public void visitGraphQLFieldDefinition_noWiringFunction_changedToSameNode() { directiveSchemaVisitor.visitGraphQLFieldDefinition(type, context); // Assert - verifyZeroInteractions(wiringMock); + verifyNoMoreInteractions(wiringMock); verify(transformerUtilWrapper).changeNode(eq(context), eq(type)); }