Skip to content

Commit 5566033

Browse files
committed
Some minor tweaks to allow extension plus @experimental annotation
1 parent fb44bdc commit 5566033

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package graphql;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
import static java.lang.annotation.ElementType.CONSTRUCTOR;
9+
import static java.lang.annotation.ElementType.FIELD;
10+
import static java.lang.annotation.ElementType.METHOD;
11+
import static java.lang.annotation.ElementType.TYPE;
12+
13+
/**
14+
* This represents code that the graphql-java project considers experimental API and may not be stable between
15+
* releases.
16+
*
17+
* In general unnecessary changes will be avoided and the code is aiming to be public one day but you should be aware that things
18+
* might change.
19+
*/
20+
@Retention(RetentionPolicy.RUNTIME)
21+
@Target(value = {CONSTRUCTOR, METHOD, TYPE, FIELD})
22+
@Documented
23+
public @interface ExperimentalApi {
24+
}

src/main/java/graphql/Internal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* This represents code that the graphql-java project considers internal code that MAY not be stable within
1313
* major releases.
1414
*
15-
* In general unecessary changes will be avoided but you should not depend on internal classes being stable
15+
* In general unnecessary changes will be avoided but you should not depend on internal classes being stable
1616
*/
1717
@Retention(RetentionPolicy.RUNTIME)
1818
@Target(value = {CONSTRUCTOR, METHOD, TYPE})

src/main/java/graphql/schema/GraphQLSchema.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.util.Arrays;
1313
import java.util.Collection;
1414
import java.util.Collections;
15+
import java.util.HashSet;
1516
import java.util.LinkedHashSet;
1617
import java.util.List;
1718
import java.util.Map;
@@ -202,8 +203,8 @@ public static class Builder {
202203
private GraphQLObjectType mutationType;
203204
private GraphQLObjectType subscriptionType;
204205
private GraphqlFieldVisibility fieldVisibility = DEFAULT_FIELD_VISIBILITY;
205-
private Set<GraphQLType> additionalTypes = Collections.emptySet();
206-
private Set<GraphQLDirective> additionalDirectives = Collections.emptySet();
206+
private Set<GraphQLType> additionalTypes = new HashSet<>();
207+
private Set<GraphQLDirective> additionalDirectives = new HashSet<>();
207208

208209
public Builder query(GraphQLObjectType.Builder builder) {
209210
return query(builder.build());
@@ -238,12 +239,21 @@ public Builder fieldVisibility(GraphqlFieldVisibility fieldVisibility) {
238239
}
239240

240241
public Builder additionalTypes(Set<GraphQLType> additionalTypes) {
241-
this.additionalTypes = additionalTypes;
242+
this.additionalTypes.addAll(additionalTypes);
243+
return this;
244+
}
245+
public Builder additionalType(GraphQLType additionalType) {
246+
this.additionalTypes.add(additionalType);
242247
return this;
243248
}
244249

245250
public Builder additionalDirectives(Set<GraphQLDirective> additionalDirectives) {
246-
this.additionalDirectives = additionalDirectives;
251+
this.additionalDirectives.addAll(additionalDirectives);
252+
return this;
253+
}
254+
255+
public Builder additionalDirective(GraphQLDirective additionalDirective) {
256+
this.additionalDirectives.add(additionalDirective);
247257
return this;
248258
}
249259

0 commit comments

Comments
 (0)