Skip to content

Commit 83b4306

Browse files
authored
Add test for deprecations on args and input fields (#293)
1 parent 594a0e2 commit 83b4306

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
type Query {
2+
persons(filter: PersonFilter @deprecated(reason: "Do not use this arg")): [Person]
3+
}
4+
5+
input PersonFilter {
6+
namePattern: String @deprecated(reason: "Do not use this field")
7+
}
8+
9+
type Person {
10+
name: String
11+
}

src/GraphQLParser.Tests/ParserTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,4 +1679,26 @@ directive @TestDirective (
16791679
if (parseComments)
16801680
directiveDef.Arguments[0].Comment.Value.ShouldBe(" comment 29");
16811681
}
1682+
1683+
// https://github.com/graphql/graphql-spec/pull/805
1684+
[Fact]
1685+
public void Should_Parse_Deprecations_On_Arg_And_InputField()
1686+
{
1687+
string text = "DeprecatedOnArgAndInputField".ReadGraphQLFile();
1688+
var document = text.Parse();
1689+
1690+
var queryDef = document.Definitions.First(x => x is GraphQLObjectTypeDefinition) as GraphQLObjectTypeDefinition;
1691+
queryDef.Name.Value.ShouldBe("Query");
1692+
var arg = queryDef.Fields[0].Arguments[0];
1693+
var dir1 = arg.Directives.ShouldNotBeNull()[0];
1694+
dir1.Name.Value.ShouldBe("deprecated");
1695+
dir1.Arguments.ShouldNotBeNull()[0].Value.ShouldBeAssignableTo<GraphQLStringValue>().Value.ShouldBe("Do not use this arg");
1696+
1697+
var inputDef = document.Definitions.First(x => x is GraphQLInputObjectTypeDefinition) as GraphQLInputObjectTypeDefinition;
1698+
inputDef.Name.Value.ShouldBe("PersonFilter");
1699+
var field = inputDef.Fields[0].ShouldNotBeNull();
1700+
var dir2 = field.Directives.ShouldNotBeNull()[0];
1701+
dir2.Name.Value.ShouldBe("deprecated");
1702+
dir2.Arguments.ShouldNotBeNull()[0].Value.ShouldBeAssignableTo<GraphQLStringValue>().Value.ShouldBe("Do not use this field");
1703+
}
16821704
}

0 commit comments

Comments
 (0)