Skip to content

Commit d109f31

Browse files
committed
fixing tests
1 parent 4bb09e3 commit d109f31

17 files changed

Lines changed: 133 additions & 79 deletions

‎src/main/java/graphql/language/DirectiveDefinition.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ private DirectiveDefinition(String name,
2929
this.directiveLocations = directiveLocations;
3030
}
3131

32+
/**
33+
* alternative to using a Builder for convenience
34+
*/
35+
public DirectiveDefinition(String name) {
36+
this(name, new ArrayList<>(), new ArrayList<>(), null, new ArrayList<>());
37+
}
38+
3239
@Override
3340
public String getName() {
3441
return name;

‎src/main/java/graphql/language/DirectiveLocation.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ private DirectiveLocation(String name, SourceLocation sourceLocation, List<Comme
2626
this.name = name;
2727
}
2828

29+
/**
30+
* alternative to using a Builder for convenience
31+
*/
32+
public DirectiveLocation(String name) {
33+
this(name, null, new ArrayList<>())
34+
;
35+
}
36+
2937
@Override
3038
public String getName() {
3139
return name;

‎src/main/java/graphql/language/EnumTypeDefinition.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public EnumTypeDefinition(String name) {
3636
}
3737

3838
public List<EnumValueDefinition> getEnumValueDefinitions() {
39-
return enumValueDefinitions;
39+
return new ArrayList<>(enumValueDefinitions);
4040
}
4141

4242
@Override

‎src/main/java/graphql/language/FieldDefinition.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,21 @@ public Builder inputValueDefinitions(List<InputValueDefinition> inputValueDefini
152152
return this;
153153
}
154154

155+
public Builder inputValueDefinition(InputValueDefinition inputValueDefinitions) {
156+
this.inputValueDefinitions.add(inputValueDefinitions);
157+
return this;
158+
}
159+
155160
public Builder directives(List<Directive> directives) {
156161
this.directives = directives;
157162
return this;
158163
}
159164

165+
public Builder directive(Directive directive) {
166+
this.directives.add(directive);
167+
return this;
168+
}
169+
160170
public FieldDefinition build() {
161171
FieldDefinition fieldDefinition = new FieldDefinition(name, type, inputValueDefinitions, directives, description, sourceLocation, comments);
162172
return fieldDefinition;

‎src/main/java/graphql/language/FragmentSpread.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,13 @@ private FragmentSpread(String name, List<Directive> directives, SourceLocation s
2121
this.directives = new ArrayList<>(directives);
2222
}
2323

24+
/**
25+
* alternative to using a Builder for convenience
26+
*/
27+
public FragmentSpread(String name) {
28+
this(name, new ArrayList<>(), null, new ArrayList<>());
29+
}
30+
2431
@Override
2532
public String getName() {
2633
return name;

‎src/main/java/graphql/language/InputValueDefinition.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ public Builder directives(List<Directive> directives) {
171171
return this;
172172
}
173173

174+
public Builder directive(Directive directive) {
175+
this.directives.add(directive);
176+
return this;
177+
}
178+
174179
public InputValueDefinition build() {
175180
InputValueDefinition inputValueDefinition = new InputValueDefinition(name,
176181
type,

‎src/main/java/graphql/language/InterfaceTypeDefinition.java‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ public InterfaceTypeDefinition(String name) {
3838
}
3939

4040
public List<FieldDefinition> getFieldDefinitions() {
41-
return definitions;
41+
return new ArrayList<>(definitions);
4242
}
4343

4444
@Override
4545
public List<Directive> getDirectives() {
46-
return directives;
46+
return new ArrayList<>(directives);
4747
}
4848

4949
@Override
@@ -141,11 +141,21 @@ public Builder definitions(List<FieldDefinition> definitions) {
141141
return this;
142142
}
143143

144+
public Builder definition(FieldDefinition definition) {
145+
this.definitions.add(definition);
146+
return this;
147+
}
148+
144149
public Builder directives(List<Directive> directives) {
145150
this.directives = directives;
146151
return this;
147152
}
148153

154+
public Builder directive(Directive directive) {
155+
this.directives.add(directive);
156+
return this;
157+
}
158+
149159
public InterfaceTypeDefinition build() {
150160
InterfaceTypeDefinition interfaceTypeDefinition = new InterfaceTypeDefinition(name,
151161
definitions,

‎src/main/java/graphql/language/ObjectTypeDefinition.java‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ public Builder implementz(List<Type> implementz) {
148148
return this;
149149
}
150150

151+
public Builder implementz(Type implement) {
152+
this.implementz.add(implement);
153+
return this;
154+
}
155+
151156
public Builder directives(List<Directive> directives) {
152157
this.directives = directives;
153158
return this;
@@ -158,6 +163,11 @@ public Builder fieldDefinitions(List<FieldDefinition> fieldDefinitions) {
158163
return this;
159164
}
160165

166+
public Builder fieldDefinition(FieldDefinition fieldDefinition) {
167+
this.fieldDefinitions.add(fieldDefinition);
168+
return this;
169+
}
170+
161171
public ObjectTypeDefinition build() {
162172
ObjectTypeDefinition objectTypeDefinition = new ObjectTypeDefinition(name,
163173
implementz,

‎src/main/java/graphql/language/ObjectValue.java‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,11 @@ public Builder objectFields(List<ObjectField> objectFields) {
9696
return this;
9797
}
9898

99+
public Builder objectField(ObjectField objectField) {
100+
this.objectFields.add(objectField);
101+
return this;
102+
}
103+
99104
public Builder comments(List<Comment> comments) {
100105
this.comments = comments;
101106
return this;

‎src/main/java/graphql/language/ScalarTypeDefinition.java‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ public class ScalarTypeDefinition extends AbstractNode<ScalarTypeDefinition> imp
2323
this.description = description;
2424
}
2525

26+
/**
27+
* alternative to using a Builder for convenience
28+
*/
29+
public ScalarTypeDefinition(String name) {
30+
this(name, new ArrayList<>(), null, null, new ArrayList<>());
31+
}
32+
2633
@Override
2734
public List<Directive> getDirectives() {
2835
return directives;

0 commit comments

Comments
 (0)