Skip to content

Commit 6df66ab

Browse files
committed
fixing tests
1 parent 525cb4d commit 6df66ab

5 files changed

Lines changed: 36 additions & 7 deletions

File tree

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,32 @@ public class Field extends AbstractNode<Field> implements Selection<Field>, Sele
2222
private final List<Directive> directives;
2323
private final SelectionSet selectionSet;
2424

25-
private Field(String name, String alias, List<Argument> arguments, List<Directive> directives, SelectionSet selectionSet) {
25+
public Field() {
26+
this(null, null, new ArrayList<>(), new ArrayList<>(), null);
27+
}
28+
29+
public Field(String name) {
30+
this(name, null, new ArrayList<>(), new ArrayList<>(), null);
31+
}
32+
33+
public Field(String name, SelectionSet selectionSet) {
34+
this(name, null, new ArrayList<>(), new ArrayList<>(), selectionSet);
35+
}
36+
37+
38+
public Field(String name, List<Argument> arguments) {
39+
this(name, null, arguments, new ArrayList<>(), null);
40+
}
41+
42+
public Field(String name, List<Argument> arguments, List<Directive> directives) {
43+
this(name, null, arguments, directives, null);
44+
}
45+
46+
public Field(String name, List<Argument> arguments, SelectionSet selectionSet) {
47+
this(name, null, arguments, new ArrayList<>(), selectionSet);
48+
}
49+
50+
public Field(String name, String alias, List<Argument> arguments, List<Directive> directives, SelectionSet selectionSet) {
2651
this.name = name;
2752
this.alias = alias;
2853
this.arguments = arguments;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ public TraversalControl accept(TraverserContext<Node> context, NodeVisitor nodeV
109109
return nodeVisitor.visitFragmentDefinition(this, context);
110110
}
111111

112-
public static Builder newBuilder() {
112+
public static Builder newFragmentDefinition() {
113113
return new Builder();
114114
}
115115

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,15 @@ public class VariableDefinition extends AbstractNode<VariableDefinition> impleme
1414
private Type type;
1515
private Value defaultValue;
1616

17-
private VariableDefinition() {
17+
public VariableDefinition() {
1818
this(null, null, null);
1919
}
2020

21+
public VariableDefinition(String name, Type type) {
22+
this(name, type, null);
23+
}
2124

22-
private VariableDefinition(String name, Type type, Value defaultValue) {
25+
public VariableDefinition(String name, Type type, Value defaultValue) {
2326
this.name = name;
2427
this.type = type;
2528
this.defaultValue = defaultValue;

‎src/main/java/graphql/parser/GraphqlAntlrToLanguage2.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ private VariableDefinition createVariableDefinition(GraphqlParser.VariableDefini
202202
}
203203

204204
public FragmentDefinition createFragmentDefinition(GraphqlParser.FragmentDefinitionContext ctx) {
205-
FragmentDefinition.Builder fragmentDefinition = FragmentDefinition.newBuilder();
205+
FragmentDefinition.Builder fragmentDefinition = FragmentDefinition.newFragmentDefinition();
206206
newNode(fragmentDefinition, ctx);
207207
fragmentDefinition.name(ctx.fragmentName().getText());
208208
fragmentDefinition.typeCondition(new TypeName(ctx.typeCondition().typeName().getText()));

‎src/test/groovy/graphql/parser/ParserTest.groovy‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ class ParserTest extends Specification {
180180
def idField = new Field("id")
181181
def nameField = new Field("name")
182182
def profilePicField = new Field("profilePic", [new Argument("size", new IntValue(50))])
183-
def selectionSet = new SelectionSet([idField, nameField, profilePicField])
184-
def fragmentDefinition = new FragmentDefinition("friendFields", new TypeName("User"), selectionSet)
183+
def selectionSet = SelectionSet.newSelectionSet().selections([idField, nameField, profilePicField]).build()
184+
def fragmentDefinition = FragmentDefinition.newFragmentDefinition().name("friendFields").typeCondition(new TypeName("User")).selectionSet(selectionSet).build()
185185

186186

187187
when:
@@ -272,6 +272,7 @@ class ParserTest extends Specification {
272272

273273
and: "expected query"
274274

275+
275276
def helloField = new Field("hello")
276277
def variableDefinition = new VariableDefinition("someTest", getOutputType)
277278
def queryDefinition = new OperationDefinition("myQuery", OperationDefinition.Operation.QUERY,

0 commit comments

Comments
 (0)