Skip to content

Commit

Permalink
Fixed: Directives are now correctly merged when declared in an extens…
Browse files Browse the repository at this point in the history
…ion file. (#665)
  • Loading branch information
michaelstaib authored Mar 27, 2019
1 parent c6b8b00 commit dff5c2b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- __type argument was named `type` instead of `name`. [spec](https://facebook.github.io/graphql/June2018/#sec-Introspection)
- The server template is now working again. [#657](https://github.com/ChilliCream/hotchocolate/issues/657)
- Non-nullable types are now validated when query uses variables. [#651](https://github.com/ChilliCream/hotchocolate/issues/651)
- Variable handling im middleware does not convert the DateTime value anymore. [#664](https://github.com/ChilliCream/hotchocolate/issues/664)
- Directives are now correctly merged when declared in an extension file. [#665](https://github.com/ChilliCream/hotchocolate/issues/665)

## [0.8.0] - 2019-03-03

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,42 @@ public void ObjectType_AddDirectives()
SchemaSyntaxSerializer.Serialize(merged).MatchSnapshot();
}

[Fact]
public void ObjectType_AddDirectivesToField()
{
// arrange
const string schema = "type Foo { bar: String } " +
"directive @foo on FIELD";
const string extensions = "extend type Foo { bar: String @foo }";

// act
var rewriter = new AddSchemaExtensionRewriter();
DocumentNode merged = rewriter.AddExtensions(
Parser.Default.Parse(schema),
Parser.Default.Parse(extensions));

// assert
SchemaSyntaxSerializer.Serialize(merged).MatchSnapshot();
}

[Fact]
public void ObjectType_DirectiveDeclaredInExtensionDoc()
{
// arrange
const string schema = "type Foo { bar: String }";
const string extensions = "extend type Foo @foo { bar: String }"
+ "directive @foo on OBJECT";

// act
var rewriter = new AddSchemaExtensionRewriter();
DocumentNode merged = rewriter.AddExtensions(
Parser.Default.Parse(schema),
Parser.Default.Parse(extensions));

// assert
SchemaSyntaxSerializer.Serialize(merged).MatchSnapshot();
}

[Fact]
public void ObjectType_AddDuplicateDirectives()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Foo {
bar: String @foo
}

directive @foo on FIELD
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type Foo @foo {
bar: String
}

directive @foo on OBJECT
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public DocumentNode AddExtensions(
current = current.WithDefinitions(definitions);
}

var context = new MergeContext(schema, extensions);
var context = new MergeContext(current, extensions);
current = RewriteDocument(current, context);
return current;
}
Expand Down

0 comments on commit dff5c2b

Please sign in to comment.