Skip to content

Commit

Permalink
Merge pull request #25 from nfl/bump-graphql-java
Browse files Browse the repository at this point in the history
bumping to the latest release of graphql-java
  • Loading branch information
vaant authored Nov 27, 2017
2 parents 923209f + 9cba259 commit 6d12cfc
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 62 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ repositories {

dependencies {
// GraphQL dependencies
compile("com.graphql-java:graphql-java:4.2")
compile("com.graphql-java:graphql-java:6.0")

// Commons dependencies
compile("org.apache.commons:commons-lang3:3.4")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ maven.central.sync=false
sonatype.username=DUMMY_SONATYPE_USER
sonatype.password=DUMMY_SONATYPE_PASSWORD

PROJECT_VERSION=1.2.6
PROJECT_VERSION=1.3.0
PROJECT_GITHUB_REPO_URL=https://github.com/nfl/glitr
PROJECT_LICENSE_URL=https://github.com/nfl/glitr/blob/master/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class CircularReferenceTest extends Specification {
type.name == AbstractRead.simpleName
then: "And make sure the implementing type has the interface registered"
def objType = glitr.typeRegistry.getType(new TypeResolutionEnvironment(new Novel(),
null, null, null, null))
null, null, null, null, null))
objType.class == GraphQLObjectType
objType.name == Novel.simpleName
objType.fieldDefinitions.name as Set == ["novel", "pageCount", "title", "reviewed"] as Set
Expand All @@ -45,7 +45,7 @@ class CircularReferenceTest extends Specification {
type.name == Readable.simpleName
then: "And make sure the implementing type has the interface registered"
def objType = glitr.typeRegistry.getType(new TypeResolutionEnvironment(new Book(),
null, null, null, null))
null, null, null, null, null))
objType.class == GraphQLObjectType
objType.name == Book.simpleName
objType.fieldDefinitions.name as Set == ["title", "synopsis"] as Set
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,26 @@ class GlitrAdditionalTypesTest extends Specification {

def "Register Additional types"() {
when: "first discovery"
Glitr glitr = GlitrBuilder.newGlitr()
.withObjectMapper(SerializationUtil.objectMapper)
.withQueryRoot(new QueryRoot())
.build()
Glitr glitr = GlitrBuilder.newGlitr()
.withObjectMapper(SerializationUtil.objectMapper)
.withQueryRoot(new QueryRoot())
.build()

def typeResolutionEnvMan = new TypeResolutionEnvironment(new Man(), null, null, null, null)
def typeResolutionEnvCyborg = new TypeResolutionEnvironment(new Cyborg(), null, null, null, null)
def typeResolutionEnvMan = new TypeResolutionEnvironment(new Man(), null, null, null, null, null)
def typeResolutionEnvCyborg = new TypeResolutionEnvironment(new Cyborg(), null, null, null, null, null)

then: "incidentally Man and Cyborg by default have not been discovered"
glitr.typeRegistry.getType(typeResolutionEnvMan) == null
glitr.typeRegistry.getType(typeResolutionEnvCyborg) == null
glitr.typeRegistry.getType(typeResolutionEnvMan) == null
glitr.typeRegistry.getType(typeResolutionEnvCyborg) == null

when: "add additional types to type registry and reload the schema"
glitr.typeRegistry.lookup(Man.class)
glitr.typeRegistry.lookup(Cyborg.class)
glitr.reloadSchema(QueryRoot.class, null)
glitr.typeRegistry.lookup(Man.class)
glitr.typeRegistry.lookup(Cyborg.class)
glitr.reloadSchema(QueryRoot.class, null)
then: "Man and Cyborg are now part of the schema"
glitr.typeRegistry.getType(typeResolutionEnvMan) != null
glitr.typeRegistry.getType(typeResolutionEnvCyborg) != null
glitr.schema.getType(Man.class.simpleName) != null
glitr.schema.getType(Cyborg.class.simpleName) != null
glitr.typeRegistry.getType(typeResolutionEnvMan) != null
glitr.typeRegistry.getType(typeResolutionEnvCyborg) != null
glitr.schema.getType(Man.class.simpleName) != null
glitr.schema.getType(Cyborg.class.simpleName) != null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ class GlitrRegisterAdditionalScalars extends Specification {

def "Register custom scalars"() {
when: "first discovery"
Glitr glitr = GlitrBuilder.newGlitr()
.withQueryRoot(new Root())
.addCustomScalar(CustomScalar.class, Scalars.GraphQLString)
.build()
def typeResolutionEnv = new TypeResolutionEnvironment(new Root(), null, null, null, null)
Glitr glitr = GlitrBuilder.newGlitr()
.withQueryRoot(new Root())
.addCustomScalar(CustomScalar.class, Scalars.GraphQLString)
.build()
def typeResolutionEnv = new TypeResolutionEnvironment(new Root(), null, null, null, null, null)
then: "make sure the scalar has been registered correctly as a GraphQLString"
glitr.typeRegistry.getType(typeResolutionEnv).getFieldDefinition("scalar").type.name == Scalars.GraphQLString.name
glitr.typeRegistry.getType(typeResolutionEnv).getFieldDefinition("scalar").type.name == Scalars.GraphQLString.name
}

def "Register twice the same custom scalar should fail"() {
when: "first discovery"
Glitr glitr = GlitrBuilder.newGlitr()
.withQueryRoot(new Root())
.addCustomScalar(CustomScalar.class, Scalars.GraphQLString)
.addCustomScalar(CustomScalar.class, Scalars.GraphQLInt)
.build()
GlitrBuilder.newGlitr()
.withQueryRoot(new Root())
.addCustomScalar(CustomScalar.class, Scalars.GraphQLString)
.addCustomScalar(CustomScalar.class, Scalars.GraphQLInt)
.build()
then: "make sure Glitr doesn't let the user attempt to register two scalars for the same java type."
def e = thrown(IllegalArgumentException)
e.getMessage().contains("You have previously registered the following Java type")
def e = thrown(IllegalArgumentException)
e.getMessage().contains("You have previously registered the following Java type")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,61 +12,57 @@ import spock.lang.Specification

class CompositeDataFetcherFactoryTest extends Specification{

def PropertyDataFetcher propertyDataFetcher = new PropertyDataFetcher()
def OverrideDataFetcher overrideDataFetcher = new OverrideDataFetcher('video', Video.class)
def OverrideDataFetcher overrideDataFetcherNullOverrideMethod = new OverrideDataFetcher('notFoundMethod', Video.class)
def OverrideDataFetcher overrideDataFetcherBatchedOverrideMethod = new OverrideDataFetcher('title', Video.class)
PropertyDataFetcher propertyDataFetcher = new PropertyDataFetcher('attribution')
OverrideDataFetcher overrideDataFetcher = new OverrideDataFetcher('video', Video.class)
OverrideDataFetcher overrideDataFetcherNullOverrideMethod = new OverrideDataFetcher('notFoundMethod', Video.class)
OverrideDataFetcher overrideDataFetcherBatchedOverrideMethod = new OverrideDataFetcher('title', Video.class)

def BatchedDataFetcher batchedDataFetcher = new UnbatchedDataFetcher()
BatchedDataFetcher batchedDataFetcher = new UnbatchedDataFetcher(new PropertyDataFetcher('copyright'))


def "All DF are batched"() {
when:"all the data fetchers are batched (exclude PropertyDataFetcher or OverrideDataFetcher)"
List<DataFetcher> dataFetchers = [propertyDataFetcher, batchedDataFetcher]
def df = (BatchedCompositeDataFetcher) CompositeDataFetcherFactory.create(dataFetchers)
List<DataFetcher> dataFetchers = [propertyDataFetcher, batchedDataFetcher]
def df = (BatchedCompositeDataFetcher) CompositeDataFetcherFactory.create(dataFetchers)
then:"it will create a BatchedCompositeDataFetcher"
df.fetchers.size() == 2
df.fetchers[0] instanceof BatchedDataFetcher
df.fetchers[1] instanceof BatchedDataFetcher
df.fetchers.size() == 2
df.fetchers[0] instanceof BatchedDataFetcher
df.fetchers[1] instanceof BatchedDataFetcher
}


def "All DF are batched with batched override method"() {
when:
List<DataFetcher> dataFetchers = [propertyDataFetcher, batchedDataFetcher, overrideDataFetcherBatchedOverrideMethod]
def df = (BatchedCompositeDataFetcher) CompositeDataFetcherFactory.create(dataFetchers)
List<DataFetcher> dataFetchers = [propertyDataFetcher, batchedDataFetcher, overrideDataFetcherBatchedOverrideMethod]
def df = (BatchedCompositeDataFetcher) CompositeDataFetcherFactory.create(dataFetchers)
then:"it will create a BatchedCompositeDataFetcher and has transformed PropertyDF and OverrideDF into batched ones"
df.fetchers.size() == 3
df.fetchers[0] instanceof BatchedDataFetcher
df.fetchers[1] instanceof BatchedDataFetcher
df.fetchers[2] instanceof BatchedDataFetcher
df.fetchers.size() == 3
df.fetchers[0] instanceof BatchedDataFetcher
df.fetchers[1] instanceof BatchedDataFetcher
df.fetchers[2] instanceof BatchedDataFetcher
}


def "All DF are un-batched"() {
when:
List<DataFetcher> dataFetchers = [propertyDataFetcher, overrideDataFetcher, overrideDataFetcherNullOverrideMethod]
def df = (CompositeDataFetcher) CompositeDataFetcherFactory.create(dataFetchers)
List<DataFetcher> dataFetchers = [propertyDataFetcher, overrideDataFetcher, overrideDataFetcherNullOverrideMethod]
def df = (CompositeDataFetcher) CompositeDataFetcherFactory.create(dataFetchers)
then:"it will create a CompositeDataFetcher"
df.fetchers.size() == 2
df.fetchers[0] instanceof PropertyDataFetcher
df.fetchers[1] instanceof OverrideDataFetcher
df.fetchers.size() == 2
df.fetchers[0] instanceof PropertyDataFetcher
df.fetchers[1] instanceof OverrideDataFetcher
}


def "Both batched and un-batched present should throw exception"() {
when:
List<DataFetcher> dataFetchers = [propertyDataFetcher, batchedDataFetcher, overrideDataFetcher]
CompositeDataFetcherFactory.create(dataFetchers)
List<DataFetcher> dataFetchers = [propertyDataFetcher, batchedDataFetcher, overrideDataFetcher]
CompositeDataFetcherFactory.create(dataFetchers)
then:
thrown(IllegalArgumentException)
thrown(IllegalArgumentException)
}



class Video {
String title;
Video video;
String title
Video video

@Batched
String getTitle(DataFetchingEnvironment environment) {
Expand Down

0 comments on commit 6d12cfc

Please sign in to comment.