Skip to content

Commit b677fcc

Browse files
authored
Merge pull request #176 from yarinvak/upgrade-gql-java-9
Upgrade gql java 9
2 parents ecdb874 + 6e0432e commit b677fcc

28 files changed

+1790
-47
lines changed

build.gradle

+15-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ gradle.projectsEvaluated {
6969

7070
dependencies {
7171
compile 'javax.validation:validation-api:1.1.0.Final'
72-
compile 'com.graphql-java:graphql-java:8.0'
72+
compile 'com.graphql-java:graphql-java:9.1'
7373

7474
// OSGi
7575
compileOnly 'org.osgi:org.osgi.core:6.0.0'
@@ -79,6 +79,7 @@ dependencies {
7979

8080
testCompile 'org.testng:testng:6.9.10'
8181
testCompile 'org.hamcrest:hamcrest-all:1.3'
82+
testCompile 'org.mockito:mockito-core:2.+'
8283
}
8384

8485
test.useTestNG()
@@ -132,6 +133,19 @@ publishing {
132133
name 'Brad Baker'
133134
134135
}
136+
developer {
137+
id 'yarinvak'
138+
name 'Yarin Vaknin'
139+
140+
}
141+
developer {
142+
id 'guy120494'
143+
name 'Guy Smorodinsky'
144+
}
145+
developer{
146+
id 'osher-sade'
147+
name 'Osher Sade'
148+
}
135149
}
136150
}
137151
}

gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ org.gradle.jvmargs=-Dfile.encoding=UTF-8
77

88
bintray.user=DUMMY_USER
99
bintray.key=DUMMY_KEY
10-
version = 5.3.1
10+
version = 5.3.1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2016 Yurii Rashkovskii
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
*/
15+
package graphql.annotations.annotationTypes;
16+
17+
import graphql.annotations.directives.Directive;
18+
19+
import java.lang.annotation.ElementType;
20+
import java.lang.annotation.Retention;
21+
import java.lang.annotation.RetentionPolicy;
22+
import java.lang.annotation.Target;
23+
24+
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
25+
@Retention(RetentionPolicy.RUNTIME)
26+
public @interface GraphQLDirectives {
27+
Directive[] value();
28+
}

src/main/java/graphql/annotations/dataFetchers/ExtensionDataFetcherWrapper.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
import static graphql.annotations.processor.util.ReflectionKit.newInstance;
2424

25-
public class ExtensionDataFetcherWrapper<T> implements DataFetcher<T>{
25+
public class ExtensionDataFetcherWrapper<T> implements DataFetcher<T> {
2626

2727
private final Class declaringClass;
2828

@@ -37,9 +37,14 @@ public ExtensionDataFetcherWrapper(Class declaringClass, DataFetcher<T> dataFetc
3737
public T get(DataFetchingEnvironment environment) {
3838
Object source = environment.getSource();
3939
if (source != null && (!declaringClass.isInstance(source)) && !(source instanceof Map)) {
40-
environment = new DataFetchingEnvironmentImpl(newInstance(declaringClass, source), environment.getArguments(), environment.getContext(),
41-
environment.getRoot(), environment.getFieldDefinition(), environment.getFields(), environment.getFieldType(), environment.getParentType(), environment.getGraphQLSchema(),
42-
environment.getFragmentsByName(), environment.getExecutionId(), environment.getSelectionSet(), environment.getFieldTypeInfo());
40+
environment = new DataFetchingEnvironmentImpl(newInstance(declaringClass, source),
41+
environment.getArguments(), environment.getContext(),
42+
environment.getRoot(), environment.getFieldDefinition(),
43+
environment.getFields(), environment.getFieldType(), environment.getParentType(),
44+
environment.getGraphQLSchema(),
45+
environment.getFragmentsByName(), environment.getExecutionId(),
46+
environment.getSelectionSet(), environment.getFieldTypeInfo(),
47+
environment.getExecutionContext());
4348
}
4449

4550
return dataFetcher.get(environment);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/**
2+
* Copyright 2016 Yurii Rashkovskii
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
*/
15+
package graphql.annotations.directives;
16+
17+
import graphql.schema.*;
18+
19+
public interface AnnotationsDirectiveWiring {
20+
/**
21+
* This is called when an object is encountered, which gives the schema directive a chance to modify the shape and behaviour
22+
* of that DSL element
23+
*
24+
* @param environment the wiring element
25+
*
26+
* @return a non null element based on the original one
27+
*/
28+
default GraphQLObjectType onObject(AnnotationsWiringEnvironment environment) {
29+
return (GraphQLObjectType) environment.getElement();
30+
}
31+
32+
/**
33+
* This is called when a field is encountered, which gives the schema directive a chance to modify the shape and behaviour
34+
* of that DSL element
35+
*
36+
* @param environment the wiring element
37+
*
38+
* @return a non null element based on the original one
39+
*/
40+
default GraphQLFieldDefinition onField(AnnotationsWiringEnvironment environment) {
41+
return (GraphQLFieldDefinition) environment.getElement();
42+
}
43+
44+
/**
45+
* This is called when an argument is encountered, which gives the schema directive a chance to modify the shape and behaviour
46+
* of that DSL element
47+
*
48+
* @param environment the wiring element
49+
*
50+
* @return a non null element based on the original one
51+
*/
52+
default GraphQLArgument onArgument(AnnotationsWiringEnvironment environment) {
53+
return (GraphQLArgument) environment.getElement();
54+
}
55+
56+
/**
57+
* This is called when an interface is encountered, which gives the schema directive a chance to modify the shape and behaviour
58+
* of that DSL element
59+
*
60+
* @param environment the wiring element
61+
*
62+
* @return a non null element based on the original one
63+
*/
64+
default GraphQLInterfaceType onInterface(AnnotationsWiringEnvironment environment) {
65+
return (GraphQLInterfaceType) environment.getElement();
66+
}
67+
68+
/**
69+
* This is called when a union is encountered, which gives the schema directive a chance to modify the shape and behaviour
70+
* of that DSL element
71+
*
72+
* @param environment the wiring element
73+
*
74+
* @return a non null element based on the original one
75+
*/
76+
default GraphQLUnionType onUnion(AnnotationsWiringEnvironment environment) {
77+
return (GraphQLUnionType) environment.getElement();
78+
}
79+
80+
/**
81+
* This is called when an enum is encountered, which gives the schema directive a chance to modify the shape and behaviour
82+
* of that DSL element
83+
*
84+
* @param environment the wiring element
85+
*
86+
* @return a non null element based on the original one
87+
*/
88+
default GraphQLEnumType onEnum(AnnotationsWiringEnvironment environment) {
89+
return (GraphQLEnumType) environment.getElement();
90+
}
91+
92+
/**
93+
* This is called when an enum value is encountered, which gives the schema directive a chance to modify the shape and behaviour
94+
* of that DSL element
95+
*
96+
* @param environment the wiring element
97+
*
98+
* @return a non null element based on the original one
99+
*/
100+
default GraphQLEnumValueDefinition onEnumValue(AnnotationsWiringEnvironment environment) {
101+
return (GraphQLEnumValueDefinition) environment.getElement();
102+
}
103+
104+
/**
105+
* This is called when a custom scalar is encountered, which gives the schema directive a chance to modify the shape and behaviour
106+
* of that DSL element
107+
*
108+
* @param environment the wiring element
109+
*
110+
* @return a non null element based on the original one
111+
*/
112+
default GraphQLScalarType onScalar(AnnotationsWiringEnvironment environment) {
113+
return (GraphQLScalarType) environment.getElement();
114+
}
115+
116+
/**
117+
* This is called when an input object is encountered, which gives the schema directive a chance to modify the shape and behaviour
118+
* of that DSL element
119+
*
120+
* @param environment the wiring element
121+
*
122+
* @return a non null element based on the original one
123+
*/
124+
default GraphQLInputObjectType onInputObjectType(AnnotationsWiringEnvironment environment) {
125+
return (GraphQLInputObjectType) environment.getElement();
126+
}
127+
128+
/**
129+
* This is called when an input object field is encountered, which gives the schema directive a chance to modify the shape and behaviour
130+
* of that DSL element
131+
*
132+
* @param environment the wiring element
133+
*
134+
* @return a non null element based on the original one
135+
*/
136+
default GraphQLInputObjectField onInputObjectField(AnnotationsWiringEnvironment environment) {
137+
return (GraphQLInputObjectField) environment.getElement();
138+
}
139+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright 2016 Yurii Rashkovskii
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
*/
15+
package graphql.annotations.directives;
16+
17+
import graphql.schema.GraphQLDirective;
18+
import graphql.schema.GraphQLDirectiveContainer;
19+
20+
public interface AnnotationsWiringEnvironment {
21+
/**
22+
* @return the runtime element in play
23+
*/
24+
GraphQLDirectiveContainer getElement();
25+
26+
/**
27+
* @return the directive that is being examined
28+
*/
29+
GraphQLDirective getDirective();
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/**
2+
* Copyright 2016 Yurii Rashkovskii
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
*/
15+
package graphql.annotations.directives;
16+
17+
import graphql.schema.GraphQLDirective;
18+
import graphql.schema.GraphQLDirectiveContainer;
19+
20+
public class AnnotationsWiringEnvironmentImpl implements AnnotationsWiringEnvironment {
21+
private final GraphQLDirectiveContainer element;
22+
private final GraphQLDirective directive;
23+
24+
public AnnotationsWiringEnvironmentImpl(GraphQLDirectiveContainer element, GraphQLDirective directive) {
25+
this.element = element;
26+
this.directive = directive;
27+
}
28+
29+
@Override
30+
public GraphQLDirectiveContainer getElement() {
31+
return element;
32+
}
33+
34+
@Override
35+
public GraphQLDirective getDirective() {
36+
return directive;
37+
}
38+
39+
@Override
40+
public boolean equals(Object o) {
41+
if (this == o) return true;
42+
if (o == null || getClass() != o.getClass()) return false;
43+
44+
AnnotationsWiringEnvironmentImpl that = (AnnotationsWiringEnvironmentImpl) o;
45+
46+
if (element != null ? !element.equals(that.element) : that.element != null) return false;
47+
return directive != null ? directive.equals(that.directive) : that.directive == null;
48+
}
49+
50+
@Override
51+
public int hashCode() {
52+
int result = element != null ? element.hashCode() : 0;
53+
result = 31 * result + (directive != null ? directive.hashCode() : 0);
54+
return result;
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/**
2+
* Copyright 2016 Yurii Rashkovskii
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
*/
15+
package graphql.annotations.directives;
16+
17+
import java.lang.annotation.ElementType;
18+
import java.lang.annotation.Retention;
19+
import java.lang.annotation.RetentionPolicy;
20+
import java.lang.annotation.Target;
21+
22+
@Target({ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER, ElementType.TYPE})
23+
@Retention(RetentionPolicy.RUNTIME)
24+
public @interface Directive {
25+
String name();
26+
27+
Class<? extends AnnotationsDirectiveWiring> wiringClass();
28+
29+
String[] argumentsValues() default {};
30+
}

0 commit comments

Comments
 (0)