Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ private void VisitSchemaDefinition(SchemaDefinitionNode node, ISyntaxWriter writ

private void VisitSchemaExtension(SchemaExtensionNode node, ISyntaxWriter writer)
{
writer.Write(Keywords.Extend);
writer.WriteSpace();
VisitSchemaDefinitionBase(node, writer);
}

Expand Down Expand Up @@ -40,6 +42,8 @@ private void VisitObjectTypeDefinition(ObjectTypeDefinitionNode node, ISyntaxWri

private void VisitObjectTypeExtension(ObjectTypeExtensionNode node, ISyntaxWriter writer)
{
writer.Write(Keywords.Extend);
writer.WriteSpace();
VisitObjectTypeDefinitionBase(node, writer);
}

Expand Down Expand Up @@ -87,6 +91,8 @@ private void VisitInterfaceTypeExtension(
InterfaceTypeExtensionNode node,
ISyntaxWriter writer)
{
writer.Write(Keywords.Extend);
writer.WriteSpace();
VisitInterfaceTypeDefinitionBase(node, writer);
}

Expand Down Expand Up @@ -134,6 +140,8 @@ private void VisitUnionTypeExtension(
UnionTypeExtensionNode node,
ISyntaxWriter writer)
{
writer.Write(Keywords.Extend);
writer.WriteSpace();
VisitUnionTypeDefinitionBase(node, writer);
}

Expand Down Expand Up @@ -168,6 +176,8 @@ private void VisitEnumTypeExtension(
EnumTypeExtensionNode node,
ISyntaxWriter writer)
{
writer.Write(Keywords.Extend);
writer.WriteSpace();
VisitEnumTypeDefinitionBase(node, writer);
}

Expand Down Expand Up @@ -205,6 +215,8 @@ private void VisitInputObjectTypeExtension(
InputObjectTypeExtensionNode node,
ISyntaxWriter writer)
{
writer.Write(Keywords.Extend);
writer.WriteSpace();
VisitInputObjectTypeDefinitionBase(node, writer);
}

Expand Down Expand Up @@ -242,6 +254,8 @@ private void VisitScalarTypeExtension(
ScalarTypeExtensionNode node,
ISyntaxWriter writer)
{
writer.Write(Keywords.Extend);
writer.WriteSpace();
VisitScalarTypeDefinitionBase(node, writer);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,19 @@ public void Serialize_ObjectTypeImplementsXYZWithIndent_OutHasIndentation()
result.MatchSnapshot();
}

[Fact]
public void Serialize_ObjectTypeExtensionDef_InOutShouldBeTheSame()
{
// arrange
string schema = "extend type Foo { bar: String baz: [Int] }";
DocumentNode document = Utf8GraphQLParser.Parse(schema);

// act
string result = document.ToString(false);

// assert
Assert.Equal(schema, result);
}

[Fact]
public void Serialize_InterfaceTypeDefNoIndent_InOutShouldBeTheSame()
Expand Down Expand Up @@ -310,6 +323,19 @@ public void Serialize_InterfaceTypeImplementsXYZWithIndent_OutHasIndentation()
result.MatchSnapshot();
}

[Fact]
public void Serialize_InterfaceTypeExtensionDef_InOutShouldBeTheSame()
{
// arrange
string schema = "extend interface Foo { bar: String baz: [Int] }";
DocumentNode document = Utf8GraphQLParser.Parse(schema);

// act
string result = document.ToString(false);

// assert
Assert.Equal(schema, result);
}

[Fact]
public void Serialize_UnionTypeDefNoIndent_InOutShouldBeTheSame()
Expand Down Expand Up @@ -395,6 +421,20 @@ public void Serialize_UnionTypeDefWithDescriptionNoIndented_OutHasIndentation()
result.MatchSnapshot();
}

[Fact]
public void Serialize_UnionTypeExtensionDef_InOutShouldBeTheSame()
{
// arrange
string schema = "extend union A = B | C";
DocumentNode document = Utf8GraphQLParser.Parse(schema);

// act
string result = document.ToString(false);

// assert
Assert.Equal(schema, result);
}

[Fact]
public void Serialize_EnumTypeDefNoIndent_InOutShouldBeTheSame()
{
Expand Down Expand Up @@ -479,6 +519,20 @@ public void Serialize_EnumTypeDefWithDescriptionNoIndented_OutHasIndentation()
result.MatchSnapshot();
}

[Fact]
public void Serialize_EnumTypeExtensionDef_InOutShouldBeTheSame()
{
// arrange
string schema = "extend enum A { B C }";
DocumentNode document = Utf8GraphQLParser.Parse(schema);

// act
string result = document.ToString(false);

// assert
Assert.Equal(schema, result);
}

[Fact]
public void Serialize_InputObjectTypeDefNoIndent_InOutShouldBeTheSame()
{
Expand Down Expand Up @@ -565,6 +619,20 @@ public void Serialize_InputObjectTypeDefWithDescriptionNoIndentt_OutHasIndentati
result.MatchSnapshot();
}

[Fact]
public void Serialize_InputObjectTypeExtensionDef_InOutShouldBeTheSame()
{
// arrange
string schema = "extend input A { b: String }";
DocumentNode document = Utf8GraphQLParser.Parse(schema);

// act
string result = document.ToString(false);

// assert
Assert.Equal(schema, result);
}

[Fact]
public void Serialize_ScalarTypeDefNoIndent_InOutShouldBeTheSame()
{
Expand Down Expand Up @@ -621,6 +689,20 @@ public void Serialize_ScalarTypeDefWithDescIndent_OutHasIndentation()
result.MatchSnapshot();
}

[Fact]
public void Serialize_ScalarTypeExtensionDef_InOutShouldBeTheSame()
{
// arrange
string schema = "extend scalar A @a @b(c: 1)";
DocumentNode document = Utf8GraphQLParser.Parse(schema);

// act
string result = document.ToString(false);

// assert
Assert.Equal(schema, result);
}

[Fact]
public void Serialize_SchemaDefWithOpNoIndent_InOutShouldBeTheSame()
{
Expand Down Expand Up @@ -676,5 +758,19 @@ public void Serialize_SchemaDefWithOpAndDirecNoIndent_OutHasIndentation()
// assert
result.MatchSnapshot();
}

[Fact]
public void Serialize_SchemaTypeExtensionDef_InOutShouldBeTheSame()
{
// arrange
string schema = "extend schema { query: A }";
DocumentNode document = Utf8GraphQLParser.Parse(schema);

// act
string result = document.ToString(false);

// assert
Assert.Equal(schema, result);
}
}
}