FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

multi line strings support by bbakerman · Pull Request #706 · graphql-java/graphql-java · GitHub

56 changes: 40 additions & 16 deletions src/main/antlr/Graphql.g4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -62,27 +62,35 @@ typeCondition : 'on' typeName;
name: NAME | FRAGMENT | QUERY | MUTATION | SUBSCRIPTION | SCHEMA | SCALAR | TYPE | INTERFACE | IMPLEMENTS | ENUM | UNION | INPUT | EXTEND | DIRECTIVE;

value :
stringValue |
IntValue |
FloatValue |
StringValue |
BooleanValue |
NullValue |
enumValue |
arrayValue |
objectValue;


valueWithVariable :
variable |
stringValue |
IntValue |
FloatValue |
StringValue |
BooleanValue |
NullValue |
enumValue |
arrayValueWithVariable |
objectValueWithVariable;


stringValue
: TripleQuotedStringValue
| StringValue
;

description : stringValue;

enumValue : name ;

// Array Value
Expand Down Expand Up @@ -115,16 +123,16 @@ nonNullType: typeName '!' | listType '!';


// Type System
typeSystemDefinition:
typeSystemDefinition: description?
schemaDefinition |
typeDefinition |
typeExtensionDefinition |
directiveDefinition
;

schemaDefinition : SCHEMA directives? '{' operationTypeDefinition+ '}';
schemaDefinition : description? SCHEMA directives? '{' operationTypeDefinition+ '}';

operationTypeDefinition : operationType ':' typeName;
operationTypeDefinition : description? operationType ':' typeName;

typeDefinition:
scalarTypeDefinition |
Expand All @@ -135,36 +143,40 @@ enumTypeDefinition |
inputObjectTypeDefinition
;

scalarTypeDefinition : SCALAR name directives?;
scalarTypeDefinition : description? SCALAR name directives?;

objectTypeDefinition : TYPE name implementsInterfaces? directives? '{' fieldDefinition+ '}';
objectTypeDefinition : description? TYPE name implementsInterfaces? directives? '{' fieldDefinition+ '}';

implementsInterfaces : IMPLEMENTS typeName+;

fieldDefinition : name argumentsDefinition? ':' type directives?;
fieldDefinition : description? name argumentsDefinition? ':' type directives?;

argumentsDefinition : '(' inputValueDefinition+ ')';

inputValueDefinition : name ':' type defaultValue? directives?;
inputValueDefinition : description? name ':' type defaultValue? directives?;

interfaceTypeDefinition : INTERFACE name directives? '{' fieldDefinition+ '}';
interfaceTypeDefinition : description? INTERFACE name directives? '{' fieldDefinition+ '}';

unionTypeDefinition : UNION name directives? '=' unionMembers;
unionTypeDefinition : description? UNION name directives? '=' unionMembers;

unionMembers:
typeName |
unionMembers '|' typeName
;

enumTypeDefinition : ENUM name directives? '{' enumValueDefinition+ '}';
enumTypeDefinition : description? ENUM name directives? '{' enumValueDefinition+ '}';

enumValueDefinition : enumValue directives?;
enumValueDefinition : description? enumValue directives?;

inputObjectTypeDefinition : INPUT name directives? '{' inputValueDefinition+ '}';
inputObjectTypeDefinition : description? INPUT name directives? '{' inputValueDefinition+ '}';

//
// type extensions dont get "description" strings according to reference implementation
// https://github.com/graphql/graphql-js/pull/927/files#diff-b9370666fe8cd9ff4dd53e89e60d26afR182
//
typeExtensionDefinition : EXTEND objectTypeDefinition;

directiveDefinition : DIRECTIVE '@' name argumentsDefinition? 'on' directiveLocations;
directiveDefinition : description? DIRECTIVE '@' name argumentsDefinition? 'on' directiveLocations;

directiveLocation : name;

Expand Down Expand Up @@ -212,7 +224,19 @@ ExponentPart : ('e'|'E') Sign? Digit+;
Digit : '0'..'9';


StringValue: '"' (~(["\\\n\r\u2028\u2029])|EscapedChar)* '"';
StringValue
: '"' ( ~["\\\n\r\u2028\u2029] | EscapedChar )* '"'
;

TripleQuotedStringValue
: '"""' TripleQuotedStringPart? '"""'
;


// Fragments never become a token of their own: they are only used inside other lexer rules
fragment TripleQuotedStringPart : ( EscapedTripleQuote | SourceCharacter )+?;
fragment EscapedTripleQuote : '\\"""';
fragment SourceCharacter :[\u0009\u000A\u000D\u0020-\uFFFF];

Comment: '#' ~[\n\r\u2028\u2029]* -> channel(2);

Expand Down
25 changes: 25 additions & 0 deletions src/main/java/graphql/language/Description.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package graphql.language;

public class Description {
public final String content;
public final SourceLocation sourceLocation;
public final boolean multiLine;

public Description(String content, SourceLocation sourceLocation, boolean multiLine) {
this.content = content;
this.sourceLocation = sourceLocation;
this.multiLine = multiLine;
}

public String getContent() {
return content;
}

public SourceLocation getSourceLocation() {
return sourceLocation;
}

public boolean isMultiLine() {
return multiLine;
}
}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

public class DirectiveDefinition extends AbstractNode<DirectiveDefinition> implements Definition<DirectiveDefinition> {
private final String name;
private Description description;
private final List<InputValueDefinition> inputValueDefinitions;
private final List<DirectiveLocation> directiveLocations;

Expand All @@ -23,6 +24,14 @@ public String getName() {
return name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

public List<InputValueDefinition> getInputValueDefinitions() {
return inputValueDefinitions;
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

public class EnumTypeDefinition extends AbstractNode<EnumTypeDefinition> implements TypeDefinition<EnumTypeDefinition> {
private final String name;
private Description description;
private final List<EnumValueDefinition> enumValueDefinitions;
private final List<Directive> directives;

Expand Down Expand Up @@ -47,6 +48,14 @@ public String getName() {
return name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

@Override
public List<Node> getChildren() {
List<Node> result = new ArrayList<>();
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public class EnumValueDefinition extends AbstractNode<EnumValueDefinition> {
private final String name;
private Description description;
private final List<Directive> directives;

public EnumValueDefinition(String name) {
Expand All @@ -22,6 +23,14 @@ public String getName() {
return name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

public List<Directive> getDirectives() {
return directives;
}
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/graphql/language/FieldDefinition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class FieldDefinition extends AbstractNode<FieldDefinition> {
private final String name;
private Type type;
private Description description;
private final List<InputValueDefinition> inputValueDefinitions;
private final List<Directive> directives;

Expand Down Expand Up @@ -40,6 +41,14 @@ public String getName() {
return name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

public List<InputValueDefinition> getInputValueDefinitions() {
return inputValueDefinitions;
}
Expand Down Expand Up @@ -73,7 +82,7 @@ public boolean isEqualTo(Node o) {

FieldDefinition that = (FieldDefinition) o;

return NodeUtil.isEqualTo(this.name, that.name);
return NodeUtil.isEqualTo(this.name,that.name) ;
}

@Override
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class InputObjectTypeDefinition extends AbstractNode<InputObjectTypeDefinition> implements TypeDefinition<InputObjectTypeDefinition> {
private final String name;
private Description description;
private final List<Directive> directives;
private final List<InputValueDefinition> inputValueDefinitions;

Expand Down Expand Up @@ -43,6 +44,14 @@ public String getName() {
return name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

@Override
public List<Node> getChildren() {
List<Node> result = new ArrayList<>();
Expand All @@ -58,8 +67,8 @@ public boolean isEqualTo(Node o) {

InputObjectTypeDefinition that = (InputObjectTypeDefinition) o;

return NodeUtil.isEqualTo(this.name, that.name);
}
return NodeUtil.isEqualTo(this.name,that.name) ;
}

@Override
public InputObjectTypeDefinition deepCopy() {
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class InputValueDefinition extends AbstractNode<InputValueDefinition> {
private final String name;
private Type type;
private Value defaultValue;
private Description description;
private final List<Directive> directives;

public InputValueDefinition(String name) {
Expand Down Expand Up @@ -44,6 +45,14 @@ public String getName() {
return name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

public Value getDefaultValue() {
return defaultValue;
}
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class InterfaceTypeDefinition extends AbstractNode<InterfaceTypeDefinition> implements TypeDefinition<InterfaceTypeDefinition> {
private final String name;
private Description description;
private final List<FieldDefinition> definitions;
private final List<Directive> directives;

Expand Down Expand Up @@ -43,6 +44,14 @@ public String getName() {
return name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

@Override
public List<Node> getChildren() {
List<Node> result = new ArrayList<>();
Expand All @@ -58,7 +67,7 @@ public boolean isEqualTo(Node o) {

InterfaceTypeDefinition that = (InterfaceTypeDefinition) o;

return NodeUtil.isEqualTo(this.name, that.name);
return NodeUtil.isEqualTo(this.name,that.name) ;
}

@Override
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class ObjectTypeDefinition extends AbstractNode<ObjectTypeDefinition> implements TypeDefinition<ObjectTypeDefinition> {
private String name;
private Description description;
private final List<Type> implementz;
private final List<Directive> directives;
private final List<FieldDefinition> fieldDefinitions;
Expand Down Expand Up @@ -53,6 +54,14 @@ public void setName(String name) {
this.name = name;
}

public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

@Override
public List<Node> getChildren() {
List<Node> result = new ArrayList<>();
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/graphql/language/ScalarTypeDefinition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

public class ScalarTypeDefinition extends AbstractNode<ScalarTypeDefinition> implements TypeDefinition<ScalarTypeDefinition> {
private final String name;
private Description description;
private final List<Directive> directives;

public ScalarTypeDefinition(String name) {
Expand Down Expand Up @@ -37,6 +38,15 @@ public String getName() {
return name;
}


public Description getDescription() {
return description;
}

public void setDescription(Description description) {
this.description = description;
}

@Override
public List<Node> getChildren() {
List<Node> result = new ArrayList<>();
Expand Down
Loading

Back | FazBrowse Home | New Git URL