Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
116 commits
Select commit Hold shift + click to select a range
71a9e72
A test to show the bug
bbakerman Feb 25, 2022
6dff2df
Merge remote-tracking branch 'origin/master' into 2740-parse_and_vali…
bbakerman May 17, 2022
8e2a771
Update InstrumentationExamples.java
appreciated Jul 7, 2023
c15da42
Add max depth option to ExecutableNormalizedOperationFactory
gnawf Jul 12, 2023
b704f0c
Add extra check on message
gnawf Jul 12, 2023
9fca81e
Add extra tests
gnawf Jul 12, 2023
d1dd724
Add docs
gnawf Jul 12, 2023
fa8cf1b
Merge pull request #3268 from gnawf/max-eno-depth
dondonz Jul 12, 2023
e54fd89
Handle repeated query directives
gnawf Jul 17, 2023
3d80faf
Merge pull request #3270 from gnawf/fix-repeated-query-directives
dondonz Jul 18, 2023
5f61821
#3267 reproduction for clear directives schema usage thing
bbakerman Jul 25, 2023
4c44fc0
Update readme
dondonz Jul 26, 2023
7f229de
Merge pull request #3273 from graphql-java/update-readme-book
dondonz Jul 26, 2023
2351ba5
#3267 reproduction updated and fix in place
bbakerman Jul 28, 2023
2eeaa6b
Started a branch for the oneOf directive support
bbakerman Jul 29, 2023
ad2b7b0
More work on @oneOf directive support
bbakerman Jul 30, 2023
7b823cc
More work on @oneOf directive support - added literal validation
bbakerman Jul 31, 2023
9b5a5b2
More work on @oneOf directive support - fixed tests that the new dire…
bbakerman Jul 31, 2023
a381658
More work on @oneOf directive support - added isOneOf support to the …
bbakerman Jul 31, 2023
345c1af
More work on @oneOf directive support - backed out validation code - …
bbakerman Jul 31, 2023
3f9cbaa
More work on @oneOf directive support - backed out validation code - …
bbakerman Aug 1, 2023
f1a3ee3
More work on @oneOf directive support - backed out validation code - …
bbakerman Aug 1, 2023
6805578
More work on @oneOf directive support - backed out validation code - …
bbakerman Aug 1, 2023
6cdf4a8
Bug 3276 - reproduction of reported bug
bbakerman Aug 1, 2023
3b09851
Bug 3276 - fix for reported bug
bbakerman Aug 1, 2023
5e4e682
Bug 3276 - more repros on the tests
bbakerman Aug 2, 2023
fbb1579
Wrap NumberFormatException
arthurscchan Aug 4, 2023
9c99711
issue 3276 - more work on fixing this bug
bbakerman Aug 5, 2023
e55ddee
added @ExperimentalApi
bbakerman Aug 5, 2023
9df21f1
Tweaked the errors messages
bbakerman Aug 6, 2023
b6a0075
Bump com.google.guava:guava from 32.1.1-jre to 32.1.2-jre
dependabot[bot] Aug 7, 2023
e4e648a
Add testng test case
arthurscchan Aug 7, 2023
0265179
Merge pull request #3282 from arthurscchan/wrap-number-format-exception
bbakerman Aug 8, 2023
f112054
deprecated default value method produces bad results
bbakerman Aug 9, 2023
b79540b
Fixed the ValuesResolverConversion to handle programmatically set nulls
bbakerman Aug 10, 2023
6f5368d
Added support for optional printing of AST definition comments.
vadimofd Aug 11, 2023
8c6c39a
Added few more test scenarios for scalars and directives.
vadimofd Aug 11, 2023
7e1b017
Fixed a couple of minor review comments.
vadimofd Aug 12, 2023
f66e845
Bump org.openjdk.jmh:jmh-core from 1.36 to 1.37
dependabot[bot] Aug 14, 2023
9e87b8c
Merge pull request #3289 from graphql-java/dependabot/gradle/org.open…
dondonz Aug 15, 2023
f19b31b
Merge pull request #3284 from graphql-java/dependabot/gradle/com.goog…
dondonz Aug 15, 2023
81a59ee
Bump org.openjdk.jmh:jmh-generator-annprocess from 1.36 to 1.37
dependabot[bot] Aug 15, 2023
466b0fd
Temporarily excluded directive and scalar comments from the test unti…
vadimofd Aug 15, 2023
07e8a84
auf Deutsch (courtesy of machine translation)
dondonz Aug 16, 2023
8c03da5
Merge pull request #3290 from graphql-java/dependabot/gradle/org.open…
dondonz Aug 21, 2023
a54bb43
Merge pull request #3286 from graphql-java/3285_default_value_problems
dondonz Aug 21, 2023
33b59d6
write query directives from ENF to AST
russellyou Aug 22, 2023
15e2c1e
write query directives from ENF to AST
russellyou Aug 22, 2023
097848a
Merge branch 'master' into schema-printer-comments
dondonz Aug 22, 2023
bbc8af7
more doc
russellyou Aug 22, 2023
980d7f0
Merge pull request #3295 from russellyou/write_query_directive_from_e…
bbakerman Aug 22, 2023
fb28011
Merge remote-tracking branch 'origin/master' into oneOf_support_branch
bbakerman Aug 22, 2023
2fb4e10
Fix bracket from merge conflict resolution
dondonz Aug 22, 2023
3b1736f
Merge pull request #3287 from vadimofd/schema-printer-comments
dondonz Aug 22, 2023
8e8e8ef
Merge remote-tracking branch 'origin/master' into oneOf_support_branch
bbakerman Aug 22, 2023
ba589a8
Merge pull request #3278 from graphql-java/3276_variable_validation_bug
bbakerman Aug 22, 2023
dc27ed1
Merge remote-tracking branch 'origin/master' into oneOf_support_branch
bbakerman Aug 22, 2023
12a00d1
Test updates
bbakerman Aug 22, 2023
fe28db5
Merge pull request #3275 from graphql-java/oneOf_support_branch
bbakerman Aug 22, 2023
6d7e50e
add directiveName as property to AppliedDirectiveLocationDetail
Aug 22, 2023
7088dee
Merge pull request #3297 from faizan-siddiqui/add-directive-name-to-l…
bbakerman Aug 23, 2023
1de1356
Added support for schema printer deprecation reason printing and fixe…
vadimofd Aug 23, 2023
72645a5
Merge pull request #3298 from vadimofd/schema-printer-deprecated-reas…
bbakerman Aug 23, 2023
ce83384
Added support for async create state in instrumentmentions
bbakerman Aug 25, 2023
85848b6
Permit parent restricted nodes to map to isolated nodes
gnawf Aug 27, 2023
1ad3562
Merge pull request #3302 from graphql-java/async-create-state
bbakerman Aug 27, 2023
eab7eeb
The last Java unit test
bbakerman Aug 27, 2023
1f03dcb
Merge pull request #3305 from graphql-java/last-java-test
bbakerman Aug 27, 2023
e1e3e64
Fix test
gnawf Aug 28, 2023
e3c7df5
Merge pull request #3304 from gnawf/fix-parent-restriction-to-isolate…
bbakerman Aug 28, 2023
5958668
Merge remote-tracking branch 'origin/master' into schema_usage_applie…
bbakerman Aug 28, 2023
28b1097
Tests now working
bbakerman Aug 28, 2023
1a39af2
Bump org.codehaus.groovy:groovy from 3.0.18 to 3.0.19
dependabot[bot] Aug 28, 2023
52c6821
Merge pull request #3307 from graphql-java/dependabot/gradle/org.code…
dondonz Aug 29, 2023
8b28f4c
Add import
dzhou-atlassian Aug 29, 2023
edd26cc
Merge pull request #3265 from appreciated/patch-1
dondonz Aug 29, 2023
f147f12
Fix OSGi bundle manifest
geichelberger Aug 30, 2023
d29f855
Update security policy with release policy timing
dondonz Sep 1, 2023
effd395
Better wording
dondonz Sep 1, 2023
c14a72f
Merge pull request #3316 from graphql-java/update-security-policy
dondonz Sep 1, 2023
d2c62f1
removed syncrhnoised from code base as much as possible for VT
bbakerman Sep 1, 2023
a602556
better code layout
bbakerman Sep 1, 2023
828d779
guava version fix for master
bbakerman Sep 3, 2023
bbc029e
Merge pull request #3321 from graphql-java/guava-version-fix-for-master
bbakerman Sep 4, 2023
ca4e08b
Bump actions/checkout from 3 to 4
dependabot[bot] Sep 4, 2023
4be2e83
Merge pull request #3325 from graphql-java/dependabot/github_actions/…
dondonz Sep 4, 2023
b965bb7
ES errors test to lock in current behavior
bbakerman Sep 7, 2023
eb353db
Merge pull request #3327 from graphql-java/some-tests-on-es-errror-co…
bbakerman Sep 8, 2023
aae3069
Merge pull request #3313 from geichelberger/fix-osgi-import
dondonz Sep 12, 2023
3c50b22
Issue 3332 - overlapping aliases should be prevented
bbakerman Sep 21, 2023
c3f9e7c
Use stable version number on clean workspace
Duhemm Sep 21, 2023
e05cd77
Relativize Antlr sources in cache key
Duhemm Sep 21, 2023
2f81ac2
Issue 3332 - the problem was unwrapped types
bbakerman Sep 21, 2023
42cfa6e
Address review feedback
Duhemm Sep 25, 2023
0a40131
The ability to get the source location of a schema element
bbakerman Sep 30, 2023
a1bedb8
The ability to get the source location of a schema element - support …
bbakerman Sep 30, 2023
4b8537f
Allow schema diff to use SDL document rather than requiring introspec…
ndejaco2 Oct 4, 2023
69fb911
Fixup import
ndejaco2 Oct 4, 2023
3c49ca0
Use private constructor and store document directly based on PR comments
ndejaco2 Oct 9, 2023
fcef0ef
Re-use common builder code
ndejaco2 Oct 9, 2023
41ee58c
Merge pull request #3344 from ndejaco2/master
bbakerman Oct 11, 2023
dd50648
Merge pull request #3340 from graphql-java/the-ability-to-get-source-…
bbakerman Oct 11, 2023
229e599
Bump com.fasterxml.jackson.core:jackson-databind from 2.15.2 to 2.15.3
dependabot[bot] Oct 16, 2023
7b5faef
Merge pull request #3350 from graphql-java/dependabot/gradle/com.fast…
dondonz Oct 16, 2023
35825ad
Merge pull request #3335 from Duhemm/build
dondonz Oct 17, 2023
517fc70
Merge pull request #3334 from graphql-java/issue-3332-overlapping-fie…
dondonz Oct 17, 2023
d070e38
Merge pull request #3272 from graphql-java/schema_usage_applied_direc…
dondonz Oct 17, 2023
4ce92a5
Merge pull request #3317 from graphql-java/removing_syncrhonised_for_…
dondonz Oct 17, 2023
7d7a336
Update DataLoader
dondonz Oct 17, 2023
42870f3
Merge pull request #3351 from graphql-java/upgrade-dataloader-3.2.1
dondonz Oct 17, 2023
4841432
@oneOf handles non-null inputs
felipe-gdr-atlassian Oct 20, 2023
ea4414f
Merge pull request #3353 from felipe-gdr/one-of-handle-non-null-inputs
dondonz Oct 22, 2023
ab23957
Merge pull request #2741 from graphql-java/2740-parse_and_validate-ca…
dondonz Oct 24, 2023
3f03bd1
Revert "A test to show that validation rules do not catch a mutation …
dondonz Oct 24, 2023
42efd9b
Merge pull request #3360 from graphql-java/revert-2741-2740-parse_and…
dondonz Oct 24, 2023
a79bebf
Merge commit '42efd9b23ef9ae7ba862d9affefe04a03a9b99cb' into 21.x-pul…
dondonz Mar 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/invoke_test_runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
if: github.repository == 'graphql-java/graphql-java'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: '14'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
MAVEN_CENTRAL_PGP_KEY: ${{ secrets.MAVEN_CENTRAL_PGP_KEY }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 11
uses: actions/setup-java@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
buildAndTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 11
uses: actions/setup-java@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
RELEASE_VERSION: ${{ github.event.inputs.version }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: gradle/wrapper-validation-action@v1
- name: Set up JDK 11
uses: actions/setup-java@v3
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ Discuss and ask questions in our Discussions: https://github.com/graphql-java/gr
This is a [GraphQL](https://github.com/graphql/graphql-spec) Java implementation.

[![Build](https://github.com/graphql-java/graphql-java/actions/workflows/master.yml/badge.svg)](https://github.com/graphql-java/graphql-java/actions/workflows/master.yml)
[![Latest Release](https://img.shields.io/maven-central/v/com.graphql-java/graphql-java?versionPrefix=20.)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/graphql-java/)
[![Latest Release](https://img.shields.io/maven-central/v/com.graphql-java/graphql-java?versionPrefix=21.)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/graphql-java/)
[![Latest Snapshot](https://img.shields.io/maven-central/v/com.graphql-java/graphql-java?label=maven-central%20snapshot&versionPrefix=0)](https://maven-badges.herokuapp.com/maven-central/com.graphql-java/graphql-java/)
[![MIT licensed](https://img.shields.io/badge/license-MIT-green)](https://github.com/graphql-java/graphql-java/blob/master/LICENSE.md)

### Documentation

We have a tutorial for beginners: [Getting started with GraphQL Java and Spring Boot](https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/)
See our tutorial for beginners: [Getting started with GraphQL Java and Spring Boot](https://www.graphql-java.com/tutorials/getting-started-with-spring-boot/)

For details how to use `graphql-java` please look at the documentation: https://www.graphql-java.com/documentation/getting-started
For further details, please see the documentation: https://www.graphql-java.com/documentation/getting-started

If you're looking to learn more, we (the maintainers) have written a book! [GraphQL with Java and Spring](https://leanpub.com/graphql-java) includes everything you need to know to build a production ready GraphQL service. The book is available on [Leanpub](https://leanpub.com/graphql-java) and [Amazon](https://www.amazon.com/GraphQL-Java-Spring-Andreas-Marek-ebook/dp/B0C96ZYWPF/).

Please take a look at our [list of releases](https://github.com/graphql-java/graphql-java/releases) if you want to learn more about new releases and the changelog.

Expand Down
8 changes: 1 addition & 7 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@

## Supported Versions

We support the latest release with security updates.

We retain the discretion to backport security updates, this is decided on a case-by-case basis.

| Version | Supported |
| ------- | ------------------ |
| v20.x | :white_check_mark: |
As stated in our [Release Policy](https://www.graphql-java.com/blog/release-policy/), we will backport critical bugfixes and security fixes for versions dating back 18 months. These fixes will be backported depending on severity and demand.

## Reporting a Vulnerability

Expand Down
70 changes: 44 additions & 26 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,52 @@ java {
}
}

def makeDevelopmentVersion(parts) {
def version = String.join("-", parts)
println "created development version: $version"
return version
}

def getDevelopmentVersion() {
def dateTime = new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date())
def gitCheckOutput = new StringBuilder()
def gitCheckError = new StringBuilder()
def gitCheck = ["git", "rev-parse", "--is-inside-work-tree"].execute()
def gitCheck = ["git", "-C", projectDir.toString(), "rev-parse", "--is-inside-work-tree"].execute()
gitCheck.waitForProcessOutput(gitCheckOutput, gitCheckError)
def isGit = gitCheckOutput.toString().trim()
if (isGit != "true") {
def version = "0.0.0-" + new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-no-git"
println "created development version: $version"
return version
return makeDevelopmentVersion(["0.0.0", dateTime, "no-git"])
}

def gitHashOutput = new StringBuilder()
def gitHashError = new StringBuilder()
def gitShortHash = ["git", "-C", projectDir.toString(), "rev-parse", "--short", "HEAD"].execute()
gitShortHash.waitForProcessOutput(gitHashOutput, gitHashError)
def gitHash = gitHashOutput.toString().trim()
if (gitHash.isEmpty()) {
println "git hash is empty: error: ${error.toString()}"
throw new IllegalStateException("git hash could not be determined")
def isCi = Boolean.parseBoolean(System.env.CI)
if (isCi) {
def gitHashOutput = new StringBuilder()
def gitHashError = new StringBuilder()
def gitShortHash = ["git", "-C", projectDir.toString(), "rev-parse", "--short", "HEAD"].execute()
gitShortHash.waitForProcessOutput(gitHashOutput, gitHashError)
def gitHash = gitHashOutput.toString().trim()
if (gitHash.isEmpty()) {
println "git hash is empty: error: ${gitHashError.toString()}"
throw new IllegalStateException("git hash could not be determined")
}

return makeDevelopmentVersion(["0.0.0", dateTime, gitHash])
}
def version = "0.0.0-" + new SimpleDateFormat('yyyy-MM-dd\'T\'HH-mm-ss').format(new Date()) + "-" + gitHash
println "created development version: $version"
version

def gitRevParseOutput = new StringBuilder()
def gitRevParseError = new StringBuilder()
def gitRevParse = ["git", "-C", projectDir.toString(), "rev-parse", "--abbrev-ref", "HEAD"].execute()
gitRevParse.waitForProcessOutput(gitRevParseOutput, gitRevParseError)
def branchName = gitRevParseOutput.toString().trim()

return makeDevelopmentVersion(["0.0.0", branchName, "SNAPSHOT"])
}

def reactiveStreamsVersion = '1.0.3'
def slf4jVersion = '2.0.7'
def releaseVersion = System.env.RELEASE_VERSION
def antlrVersion = '4.11.1' // https://mvnrepository.com/artifact/org.antlr/antlr4-runtime
def guavaVersion = '32.1.1-jre'
def guavaVersion = '32.1.2-jre'
version = releaseVersion ? releaseVersion : getDevelopmentVersion()
group = 'com.graphql-java'

Expand Down Expand Up @@ -87,17 +102,17 @@ dependencies {
compileOnly 'org.jetbrains:annotations:24.0.1'
implementation 'org.antlr:antlr4-runtime:' + antlrVersion
implementation 'org.slf4j:slf4j-api:' + slf4jVersion
api 'com.graphql-java:java-dataloader:3.2.0'
api 'com.graphql-java:java-dataloader:3.2.1'
api 'org.reactivestreams:reactive-streams:' + reactiveStreamsVersion
antlr 'org.antlr:antlr4:' + antlrVersion
implementation 'com.google.guava:guava:' + guavaVersion
testImplementation group: 'junit', name: 'junit', version: '4.13.2'
testImplementation 'org.spockframework:spock-core:2.0-groovy-3.0'
testImplementation 'org.codehaus.groovy:groovy:3.0.18'
testImplementation 'org.codehaus.groovy:groovy-json:3.0.18'
testImplementation 'org.codehaus.groovy:groovy:3.0.19'
testImplementation 'org.codehaus.groovy:groovy-json:3.0.19'
testImplementation 'com.google.code.gson:gson:2.10.1'
testImplementation 'org.eclipse.jetty:jetty-server:11.0.15'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.15.2'
testImplementation 'com.fasterxml.jackson.core:jackson-databind:2.15.3'
testImplementation 'org.slf4j:slf4j-simple:' + slf4jVersion
testImplementation 'org.awaitility:awaitility-groovy:4.2.0'
testImplementation 'com.github.javafaker:javafaker:1.0.2'
Expand All @@ -107,10 +122,10 @@ dependencies {

testImplementation 'org.testng:testng:7.8.0' // use for reactive streams test inheritance

testImplementation 'org.openjdk.jmh:jmh-core:1.36'
testAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.36'
jmh 'org.openjdk.jmh:jmh-core:1.36'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.36'
testImplementation 'org.openjdk.jmh:jmh-core:1.37'
testAnnotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
jmh 'org.openjdk.jmh:jmh-core:1.37'
jmh 'org.openjdk.jmh:jmh-generator-annprocess:1.37'
}

shadowJar {
Expand Down Expand Up @@ -155,7 +170,7 @@ shadowJar {
bnd('''
-exportcontents: graphql.*
-removeheaders: Private-Package
Import-Package: !com.google.*,!org.checkerframework.*,!javax.annotation.*,!graphql.com.google.*,!org.antlr.*,!graphql.org.antlr.*,!sun.misc.*,*
Import-Package: !android.os.*,!com.google.*,!org.checkerframework.*,!javax.annotation.*,!graphql.com.google.*,!org.antlr.*,!graphql.org.antlr.*,!sun.misc.*,*
''')
}

Expand Down Expand Up @@ -203,7 +218,10 @@ generateGrammarSource {
arguments += ["-visitor"]
outputDirectory = file("${project.buildDir}/generated-src/antlr/main/graphql/parser/antlr")
}
generateGrammarSource.inputs.dir('src/main/antlr')
generateGrammarSource.inputs
.dir('src/main/antlr')
.withPropertyName('sourceDir')
.withPathSensitivity(PathSensitivity.RELATIVE)


task sourcesJar(type: Jar) {
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/graphql/Directives.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import static graphql.introspection.Introspection.DirectiveLocation.FRAGMENT_SPREAD;
import static graphql.introspection.Introspection.DirectiveLocation.INLINE_FRAGMENT;
import static graphql.introspection.Introspection.DirectiveLocation.INPUT_FIELD_DEFINITION;
import static graphql.introspection.Introspection.DirectiveLocation.INPUT_OBJECT;
import static graphql.introspection.Introspection.DirectiveLocation.SCALAR;
import static graphql.language.DirectiveLocation.newDirectiveLocation;
import static graphql.language.InputValueDefinition.newInputValueDefinition;
Expand All @@ -31,10 +32,13 @@ public class Directives {

private static final String SPECIFIED_BY = "specifiedBy";
private static final String DEPRECATED = "deprecated";
private static final String ONE_OF = "oneOf";

public static final String NO_LONGER_SUPPORTED = "No longer supported";
public static final DirectiveDefinition DEPRECATED_DIRECTIVE_DEFINITION;
public static final DirectiveDefinition SPECIFIED_BY_DIRECTIVE_DEFINITION;
@ExperimentalApi
public static final DirectiveDefinition ONE_OF_DIRECTIVE_DEFINITION;


static {
Expand Down Expand Up @@ -65,6 +69,12 @@ public class Directives {
.type(newNonNullType(newTypeName().name("String").build()).build())
.build())
.build();

ONE_OF_DIRECTIVE_DEFINITION = DirectiveDefinition.newDirectiveDefinition()
.name(ONE_OF)
.directiveLocation(newDirectiveLocation().name(INPUT_OBJECT.name()).build())
.description(createDescription("Indicates an Input Object is a OneOf Input Object."))
.build();
}

public static final GraphQLDirective IncludeDirective = GraphQLDirective.newDirective()
Expand Down Expand Up @@ -119,6 +129,14 @@ public class Directives {
.definition(SPECIFIED_BY_DIRECTIVE_DEFINITION)
.build();

@ExperimentalApi
public static final GraphQLDirective OneOfDirective = GraphQLDirective.newDirective()
.name(ONE_OF)
.description("Indicates an Input Object is a OneOf Input Object.")
.validLocations(INPUT_OBJECT)
.definition(ONE_OF_DIRECTIVE_DEFINITION)
.build();

private static Description createDescription(String s) {
return new Description(s, null, false);
}
Expand Down
51 changes: 27 additions & 24 deletions src/main/java/graphql/GraphQL.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package graphql;

import graphql.execution.AbortExecutionException;
import graphql.execution.Async;
import graphql.execution.AsyncExecutionStrategy;
import graphql.execution.AsyncSerialExecutionStrategy;
import graphql.execution.DataFetcherExceptionHandler;
Expand Down Expand Up @@ -421,31 +422,33 @@ public CompletableFuture<ExecutionResult> executeAsync(ExecutionInput executionI
if (logNotSafe.isDebugEnabled()) {
logNotSafe.debug("Executing request. operation name: '{}'. query: '{}'. variables '{}'", executionInput.getOperationName(), executionInput.getQuery(), executionInput.getVariables());
}
executionInput = ensureInputHasId(executionInput);
ExecutionInput executionInputWithId = ensureInputHasId(executionInput);

InstrumentationState instrumentationState = instrumentation.createState(new InstrumentationCreateStateParameters(this.graphQLSchema, executionInput));
try {
InstrumentationExecutionParameters inputInstrumentationParameters = new InstrumentationExecutionParameters(executionInput, this.graphQLSchema, instrumentationState);
executionInput = instrumentation.instrumentExecutionInput(executionInput, inputInstrumentationParameters, instrumentationState);

CompletableFuture<ExecutionResult> beginExecutionCF = new CompletableFuture<>();
InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(executionInput, this.graphQLSchema, instrumentationState);
InstrumentationContext<ExecutionResult> executionInstrumentation = nonNullCtx(instrumentation.beginExecution(instrumentationParameters, instrumentationState));
executionInstrumentation.onDispatched(beginExecutionCF);

GraphQLSchema graphQLSchema = instrumentation.instrumentSchema(this.graphQLSchema, instrumentationParameters, instrumentationState);

CompletableFuture<ExecutionResult> executionResult = parseValidateAndExecute(executionInput, graphQLSchema, instrumentationState);
//
// finish up instrumentation
executionResult = executionResult.whenComplete(completeInstrumentationCtxCF(executionInstrumentation, beginExecutionCF));
//
// allow instrumentation to tweak the result
executionResult = executionResult.thenCompose(result -> instrumentation.instrumentExecutionResult(result, instrumentationParameters, instrumentationState));
return executionResult;
} catch (AbortExecutionException abortException) {
return handleAbortException(executionInput, instrumentationState, abortException);
}
CompletableFuture<InstrumentationState> instrumentationStateCF = instrumentation.createStateAsync(new InstrumentationCreateStateParameters(this.graphQLSchema, executionInput));
return Async.orNullCompletedFuture(instrumentationStateCF).thenCompose(instrumentationState -> {
try {
InstrumentationExecutionParameters inputInstrumentationParameters = new InstrumentationExecutionParameters(executionInputWithId, this.graphQLSchema, instrumentationState);
ExecutionInput instrumentedExecutionInput = instrumentation.instrumentExecutionInput(executionInputWithId, inputInstrumentationParameters, instrumentationState);

CompletableFuture<ExecutionResult> beginExecutionCF = new CompletableFuture<>();
InstrumentationExecutionParameters instrumentationParameters = new InstrumentationExecutionParameters(instrumentedExecutionInput, this.graphQLSchema, instrumentationState);
InstrumentationContext<ExecutionResult> executionInstrumentation = nonNullCtx(instrumentation.beginExecution(instrumentationParameters, instrumentationState));
executionInstrumentation.onDispatched(beginExecutionCF);

GraphQLSchema graphQLSchema = instrumentation.instrumentSchema(this.graphQLSchema, instrumentationParameters, instrumentationState);

CompletableFuture<ExecutionResult> executionResult = parseValidateAndExecute(instrumentedExecutionInput, graphQLSchema, instrumentationState);
//
// finish up instrumentation
executionResult = executionResult.whenComplete(completeInstrumentationCtxCF(executionInstrumentation, beginExecutionCF));
//
// allow instrumentation to tweak the result
executionResult = executionResult.thenCompose(result -> instrumentation.instrumentExecutionResult(result, instrumentationParameters, instrumentationState));
return executionResult;
} catch (AbortExecutionException abortException) {
return handleAbortException(executionInput, instrumentationState, abortException);
}
});
}

private CompletableFuture<ExecutionResult> handleAbortException(ExecutionInput executionInput, InstrumentationState instrumentationState, AbortExecutionException abortException) {
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/graphql/execution/Async.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import graphql.Assert;
import graphql.Internal;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;
Expand Down Expand Up @@ -207,4 +209,15 @@ public static <T> CompletableFuture<T> exceptionallyCompletedFuture(Throwable ex
return result;
}

/**
* If the passed in CompletableFuture is null then it creates a CompletableFuture that resolves to null
*
* @param completableFuture the CF to use
* @param <T> for two
*
* @return the completableFuture if it's not null or one that always resoles to null
*/
public static <T> @NotNull CompletableFuture<T> orNullCompletedFuture(@Nullable CompletableFuture<T> completableFuture) {
return completableFuture != null ? completableFuture : CompletableFuture.completedFuture(null);
}
}
Loading