Skip to content

Commit c0204d5

Browse files
committed
Working towards deprecating public constructors and instead favouring builders of the major API objects
1 parent 720b315 commit c0204d5

13 files changed

Lines changed: 271 additions & 5 deletions

src/main/java/graphql/GraphQL.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public class GraphQL {
108108
* @deprecated use the {@link #newGraphQL(GraphQLSchema)} builder instead. This will be removed in a future version.
109109
*/
110110
@Internal
111+
@Deprecated
111112
public GraphQL(GraphQLSchema graphQLSchema) {
112113
//noinspection deprecation
113114
this(graphQLSchema, null, null);
@@ -122,6 +123,7 @@ public GraphQL(GraphQLSchema graphQLSchema) {
122123
* @deprecated use the {@link #newGraphQL(GraphQLSchema)} builder instead. This will be removed in a future version.
123124
*/
124125
@Internal
126+
@Deprecated
125127
public GraphQL(GraphQLSchema graphQLSchema, ExecutionStrategy queryStrategy) {
126128
//noinspection deprecation
127129
this(graphQLSchema, queryStrategy, null);
@@ -137,6 +139,7 @@ public GraphQL(GraphQLSchema graphQLSchema, ExecutionStrategy queryStrategy) {
137139
* @deprecated use the {@link #newGraphQL(GraphQLSchema)} builder instead. This will be removed in a future version.
138140
*/
139141
@Internal
142+
@Deprecated
140143
public GraphQL(GraphQLSchema graphQLSchema, ExecutionStrategy queryStrategy, ExecutionStrategy mutationStrategy) {
141144
this(graphQLSchema, queryStrategy, mutationStrategy, null, DEFAULT_EXECUTION_ID_PROVIDER, SimpleInstrumentation.INSTANCE, NoOpPreparsedDocumentProvider.INSTANCE);
142145
}
@@ -152,6 +155,7 @@ public GraphQL(GraphQLSchema graphQLSchema, ExecutionStrategy queryStrategy, Exe
152155
* @deprecated use the {@link #newGraphQL(GraphQLSchema)} builder instead. This will be removed in a future version.
153156
*/
154157
@Internal
158+
@Deprecated
155159
public GraphQL(GraphQLSchema graphQLSchema, ExecutionStrategy queryStrategy, ExecutionStrategy mutationStrategy, ExecutionStrategy subscriptionStrategy) {
156160
this(graphQLSchema, queryStrategy, mutationStrategy, subscriptionStrategy, DEFAULT_EXECUTION_ID_PROVIDER, SimpleInstrumentation.INSTANCE, NoOpPreparsedDocumentProvider.INSTANCE);
157161
}

src/main/java/graphql/schema/GraphQLArgument.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package graphql.schema;
22

33

4+
import graphql.Internal;
45
import graphql.PublicApi;
56
import graphql.language.InputValueDefinition;
67
import graphql.util.FpKit;
@@ -48,14 +49,41 @@ public class GraphQLArgument implements GraphQLDirectiveContainer {
4849
private final InputValueDefinition definition;
4950
private final List<GraphQLDirective> directives;
5051

52+
/**
53+
* @param name the arg name
54+
* @param description the arg description
55+
* @param type the arg type
56+
* @param defaultValue the default value
57+
*
58+
* @deprecated use the {@link #newArgument()} builder pattern instead, as this constructor will be made private in a future version.
59+
*/
60+
@Internal
61+
@Deprecated
5162
public GraphQLArgument(String name, String description, GraphQLInputType type, Object defaultValue) {
5263
this(name, description, type, defaultValue, null);
5364
}
5465

66+
/**
67+
* @param name the arg name
68+
* @param type the arg type
69+
*
70+
* @deprecated use the {@link #newArgument()} builder pattern instead, as this constructor will be made private in a future version.
71+
*/
72+
@Internal
73+
@Deprecated
5574
public GraphQLArgument(String name, GraphQLInputType type) {
5675
this(name, null, type, null, null);
5776
}
5877

78+
/**
79+
* @param name the arg name
80+
* @param description the arg description
81+
* @param type the arg type
82+
* @param defaultValue the default value
83+
* @param definition the AST definition
84+
*
85+
* @deprecated use the {@link #newArgument()} builder pattern instead, as this constructor will be made private in a future version.
86+
*/
5987
public GraphQLArgument(String name, String description, GraphQLInputType type, Object defaultValue, InputValueDefinition definition) {
6088
this(name, description, type, defaultValue, null, definition, Collections.emptyList());
6189
}

src/main/java/graphql/schema/GraphQLEnumType.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,30 @@ public Object parseLiteral(Object input) {
7575
};
7676

7777

78+
/**
79+
* @param name the name
80+
* @param description the description
81+
* @param values the values
82+
*
83+
* @deprecated use the {@link #newEnum()} builder pattern instead, as this constructor will be made private in a future version.
84+
*/
7885
@Internal
86+
@Deprecated
7987
public GraphQLEnumType(String name, String description, List<GraphQLEnumValueDefinition> values) {
8088
this(name, description, values, emptyList(), null);
8189
}
8290

91+
/**
92+
* @param name the name
93+
* @param description the description
94+
* @param values the values
95+
* @param directives the directives on this type element
96+
* @param definition the AST definition
97+
*
98+
* @deprecated use the {@link #newEnum()} builder pattern instead, as this constructor will be made private in a future version.
99+
*/
83100
@Internal
101+
@Deprecated
84102
public GraphQLEnumType(String name, String description, List<GraphQLEnumValueDefinition> values, List<GraphQLDirective> directives, EnumTypeDefinition definition) {
85103
assertValidName(name);
86104
assertNotNull(directives, "directives cannot be null");

src/main/java/graphql/schema/GraphQLEnumValueDefinition.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,44 @@ public class GraphQLEnumValueDefinition implements GraphQLDirectiveContainer {
3535
private final String deprecationReason;
3636
private final List<GraphQLDirective> directives;
3737

38+
/**
39+
* @param name the name
40+
* @param description the description
41+
* @param value the value
42+
*
43+
* @deprecated use the {@link #newEnumValueDefinition()} builder pattern instead, as this constructor will be made private in a future version.
44+
*/
3845
@Internal
46+
@Deprecated
3947
public GraphQLEnumValueDefinition(String name, String description, Object value) {
4048
this(name, description, value, null, emptyList());
4149
}
4250

51+
/**
52+
* @param name the name
53+
* @param description the description
54+
* @param value the value
55+
* @param deprecationReason the deprecation reasons
56+
*
57+
* @deprecated use the {@link #newEnumValueDefinition()} builder pattern instead, as this constructor will be made private in a future version.
58+
*/
4359
@Internal
60+
@Deprecated
4461
public GraphQLEnumValueDefinition(String name, String description, Object value, String deprecationReason) {
4562
this(name, description, value, deprecationReason, emptyList());
4663
}
4764

65+
/**
66+
* @param name the name
67+
* @param description the description
68+
* @param value the value
69+
* @param deprecationReason the deprecation reasons
70+
* @param directives the directives on this type element
71+
*
72+
* @deprecated use the {@link #newEnumValueDefinition()} builder pattern instead, as this constructor will be made private in a future version.
73+
*/
4874
@Internal
75+
@Deprecated
4976
public GraphQLEnumValueDefinition(String name, String description, Object value, String deprecationReason, List<GraphQLDirective> directives) {
5077
assertValidName(name);
5178
assertNotNull(directives, "directives cannot be null");

src/main/java/graphql/schema/GraphQLFieldDefinition.java

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,36 @@ public class GraphQLFieldDefinition implements GraphQLDirectiveContainer {
4444
private final FieldDefinition definition;
4545

4646

47-
@Deprecated
47+
/**
48+
* @param name the name
49+
* @param description the description
50+
* @param type the field type
51+
* @param dataFetcher the field data fetcher
52+
* @param arguments the field arguments
53+
* @param deprecationReason the deprecation reason
54+
*
55+
* @deprecated use the {@link #newFieldDefinition()} builder pattern instead, as this constructor will be made private in a future version.
56+
*/
4857
@Internal
58+
@Deprecated
4959
public GraphQLFieldDefinition(String name, String description, GraphQLOutputType type, DataFetcher<?> dataFetcher, List<GraphQLArgument> arguments, String deprecationReason) {
5060
this(name, description, type, DataFetcherFactories.useDataFetcher(dataFetcher), arguments, deprecationReason, Collections.emptyList(), null);
5161
}
5262

63+
/**
64+
* @param name the name
65+
* @param description the description
66+
* @param type the field type
67+
* @param dataFetcherFactory the field data fetcher factory
68+
* @param arguments the field arguments
69+
* @param deprecationReason the deprecation reason
70+
* @param directives the directives on this type element
71+
* @param definition the AST definition
72+
*
73+
* @deprecated use the {@link #newFieldDefinition()} builder pattern instead, as this constructor will be made private in a future version.
74+
*/
5375
@Internal
76+
@Deprecated
5477
public GraphQLFieldDefinition(String name, String description, GraphQLOutputType type, DataFetcherFactory dataFetcherFactory, List<GraphQLArgument> arguments, String deprecationReason, List<GraphQLDirective> directives, FieldDefinition definition) {
5578
this.directives = directives;
5679
assertValidName(name);
@@ -152,7 +175,7 @@ public TraversalControl accept(TraverserContext<GraphQLType> context, GraphQLTyp
152175

153176
@Override
154177
public List<GraphQLType> getChildren() {
155-
List<GraphQLType> children = new ArrayList<>();
178+
List<GraphQLType> children = new ArrayList<>();
156179
children.add(type);
157180
children.addAll(arguments);
158181
children.addAll(directives);

src/main/java/graphql/schema/GraphQLInputObjectField.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import graphql.util.TraverserContext;
99

1010
import java.util.ArrayList;
11-
import java.util.Collections;
1211
import java.util.LinkedHashMap;
1312
import java.util.List;
1413
import java.util.Map;
@@ -38,17 +37,44 @@ public class GraphQLInputObjectField implements GraphQLDirectiveContainer {
3837
private final InputValueDefinition definition;
3938
private final List<GraphQLDirective> directives;
4039

40+
/**
41+
* @param name the name
42+
* @param type the field type
43+
*
44+
* @deprecated use the {@link #newInputObjectField()} builder pattern instead, as this constructor will be made private in a future version.
45+
*/
4146
@Internal
47+
@Deprecated
4248
public GraphQLInputObjectField(String name, GraphQLInputType type) {
4349
this(name, null, type, null, emptyList(), null);
4450
}
4551

52+
/**
53+
* @param name the name
54+
* @param description the description
55+
* @param type the field type
56+
* @param defaultValue the default value
57+
*
58+
* @deprecated use the {@link #newInputObjectField()} builder pattern instead, as this constructor will be made private in a future version.
59+
*/
4660
@Internal
61+
@Deprecated
4762
public GraphQLInputObjectField(String name, String description, GraphQLInputType type, Object defaultValue) {
4863
this(name, description, type, defaultValue, emptyList(), null);
4964
}
5065

66+
/**
67+
* @param name the name
68+
* @param description the description
69+
* @param type the field type
70+
* @param defaultValue the default value
71+
* @param directives the directives on this type element
72+
* @param definition the AST definition
73+
*
74+
* @deprecated use the {@link #newInputObjectField()} builder pattern instead, as this constructor will be made private in a future version.
75+
*/
5176
@Internal
77+
@Deprecated
5278
public GraphQLInputObjectField(String name, String description, GraphQLInputType type, Object defaultValue, List<GraphQLDirective> directives, InputValueDefinition definition) {
5379
assertValidName(name);
5480
assertNotNull(type, "type can't be null");

src/main/java/graphql/schema/GraphQLInputObjectType.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,30 @@ public class GraphQLInputObjectType implements GraphQLType, GraphQLInputType, Gr
3535
private final InputObjectTypeDefinition definition;
3636
private final List<GraphQLDirective> directives;
3737

38+
/**
39+
* @param name the name
40+
* @param description the description
41+
* @param fields the fields
42+
*
43+
* @deprecated use the {@link #newInputObject()} builder pattern instead, as this constructor will be made private in a future version.
44+
*/
3845
@Internal
46+
@Deprecated
3947
public GraphQLInputObjectType(String name, String description, List<GraphQLInputObjectField> fields) {
4048
this(name, description, fields, emptyList(), null);
4149
}
4250

51+
/**
52+
* @param name the name
53+
* @param description the description
54+
* @param fields the fields
55+
* @param directives the directives on this type element
56+
* @param definition the AST definition
57+
*
58+
* @deprecated use the {@link #newInputObject()} builder pattern instead, as this constructor will be made private in a future version.
59+
*/
4360
@Internal
61+
@Deprecated
4462
public GraphQLInputObjectType(String name, String description, List<GraphQLInputObjectField> fields, List<GraphQLDirective> directives, InputObjectTypeDefinition definition) {
4563
assertValidName(name);
4664
assertNotNull(fields, "fields can't be null");

src/main/java/graphql/schema/GraphQLInterfaceType.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,32 @@ public class GraphQLInterfaceType implements GraphQLType, GraphQLOutputType, Gra
4141
private final InterfaceTypeDefinition definition;
4242
private final List<GraphQLDirective> directives;
4343

44+
/**
45+
* @param name the name
46+
* @param description the description
47+
* @param fieldDefinitions the fields
48+
* @param typeResolver the type resolver function
49+
*
50+
* @deprecated use the {@link #newInterface()} builder pattern instead, as this constructor will be made private in a future version.
51+
*/
4452
@Internal
53+
@Deprecated
4554
public GraphQLInterfaceType(String name, String description, List<GraphQLFieldDefinition> fieldDefinitions, TypeResolver typeResolver) {
4655
this(name, description, fieldDefinitions, typeResolver, Collections.emptyList(), null);
4756
}
4857

58+
/**
59+
* @param name the name
60+
* @param description the description
61+
* @param fieldDefinitions the fields
62+
* @param typeResolver the type resolver function
63+
* @param directives the directives on this type element
64+
* @param definition the AST definition
65+
*
66+
* @deprecated use the {@link #newInterface()} builder pattern instead, as this constructor will be made private in a future version.
67+
*/
4968
@Internal
69+
@Deprecated
5070
public GraphQLInterfaceType(String name, String description, List<GraphQLFieldDefinition> fieldDefinitions, TypeResolver typeResolver, List<GraphQLDirective> directives, InterfaceTypeDefinition definition) {
5171
assertValidName(name);
5272
assertNotNull(typeResolver, "typeResolver can't null");

src/main/java/graphql/schema/GraphQLObjectType.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.util.Map;
1414
import java.util.function.Consumer;
1515
import java.util.function.UnaryOperator;
16-
import java.util.stream.Collectors;
1716

1817
import static graphql.Assert.assertNotNull;
1918
import static graphql.Assert.assertValidName;
@@ -42,13 +41,33 @@ public class GraphQLObjectType implements GraphQLType, GraphQLOutputType, GraphQ
4241
private final List<GraphQLDirective> directives;
4342
private final ObjectTypeDefinition definition;
4443

44+
/**
45+
* @param name the name
46+
* @param description the description
47+
* @param fieldDefinitions the fields
48+
* @param interfaces the possible interfaces
49+
*
50+
* @deprecated use the {@link #newObject()} builder pattern instead, as this constructor will be made private in a future version.
51+
*/
4552
@Internal
53+
@Deprecated
4654
public GraphQLObjectType(String name, String description, List<GraphQLFieldDefinition> fieldDefinitions,
4755
List<GraphQLOutputType> interfaces) {
4856
this(name, description, fieldDefinitions, interfaces, emptyList(), null);
4957
}
5058

59+
/**
60+
* @param name the name
61+
* @param description the description
62+
* @param fieldDefinitions the fields
63+
* @param interfaces the possible interfaces
64+
* @param directives the directives on this type element
65+
* @param definition the AST definition
66+
*
67+
* @deprecated use the {@link #newObject()} builder pattern instead, as this constructor will be made private in a future version.
68+
*/
5169
@Internal
70+
@Deprecated
5271
public GraphQLObjectType(String name, String description, List<GraphQLFieldDefinition> fieldDefinitions,
5372
List<GraphQLOutputType> interfaces, List<GraphQLDirective> directives, ObjectTypeDefinition definition) {
5473
assertValidName(name);

src/main/java/graphql/schema/GraphQLScalarType.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,30 @@ public class GraphQLScalarType implements GraphQLType, GraphQLInputType, GraphQL
4242
private final ScalarTypeDefinition definition;
4343
private final List<GraphQLDirective> directives;
4444

45+
/**
46+
* @param name the name
47+
* @param description the description
48+
* @param coercing the coercing function
49+
*
50+
* @deprecated use the {@link #newScalar()} builder pattern instead, as this constructor will be made private in a future version.
51+
*/
4552
@Internal
53+
@Deprecated
4654
public GraphQLScalarType(String name, String description, Coercing coercing) {
4755
this(name, description, coercing, emptyList(), null);
4856
}
4957

58+
/**
59+
* @param name the name
60+
* @param description the description
61+
* @param coercing the coercing function
62+
* @param directives the directives on this type element
63+
* @param definition the AST definition
64+
*
65+
* @deprecated use the {@link #newScalar()} builder pattern instead, as this constructor will be made private in a future version.
66+
*/
5067
@Internal
68+
@Deprecated
5169
public GraphQLScalarType(String name, String description, Coercing coercing, List<GraphQLDirective> directives, ScalarTypeDefinition definition) {
5270
assertValidName(name);
5371
assertNotNull(coercing, "coercing can't be null");

0 commit comments

Comments
 (0)