Skip to content

Commit 3951ad4

Browse files
authored
Allow deprecated directive on arguments (#541)
1 parent e892575 commit 3951ad4

File tree

6 files changed

+31
-8
lines changed

6 files changed

+31
-8
lines changed

example/social/introspect.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"description": "Marks an element of a GraphQL schema as no longer supported.",
1818
"locations": [
1919
"FIELD_DEFINITION",
20-
"ENUM_VALUE"
20+
"ENUM_VALUE",
21+
"ARGUMENT_DEFINITION"
2122
],
2223
"name": "deprecated"
2324
},

example/starwars/introspect.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
"description": "Marks an element of a GraphQL schema as no longer supported.",
1818
"locations": [
1919
"FIELD_DEFINITION",
20-
"ENUM_VALUE"
20+
"ENUM_VALUE",
21+
"ARGUMENT_DEFINITION"
2122
],
2223
"name": "deprecated"
2324
},

graphql_test.go

+19-1
Original file line numberDiff line numberDiff line change
@@ -1701,6 +1701,23 @@ func TestEnums(t *testing.T) {
17011701
})
17021702
}
17031703

1704+
type testDeprecatedArgsResolver struct{}
1705+
1706+
func (r *testDeprecatedArgsResolver) A(args struct{ B *string }) int32 {
1707+
return 0
1708+
}
1709+
1710+
func TestDeprecatedArgs(t *testing.T) {
1711+
graphql.MustParseSchema(`
1712+
schema {
1713+
query: Query
1714+
}
1715+
type Query {
1716+
a(b: String @deprecated): Int!
1717+
}
1718+
`, &testDeprecatedArgsResolver{})
1719+
}
1720+
17041721
func TestInlineFragments(t *testing.T) {
17051722
gqltesting.RunTests(t, []*gqltesting.Test{
17061723
{
@@ -2474,7 +2491,8 @@ func TestIntrospection(t *testing.T) {
24742491
"description": "Marks an element of a GraphQL schema as no longer supported.",
24752492
"locations": [
24762493
"FIELD_DEFINITION",
2477-
"ENUM_VALUE"
2494+
"ENUM_VALUE",
2495+
"ARGUMENT_DEFINITION"
24782496
],
24792497
"args": [
24802498
{

internal/common/values.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@ func ParseArgumentList(l *Lexer) types.ArgumentList {
2727
name := l.ConsumeIdentWithLoc()
2828
l.ConsumeToken(':')
2929
value := ParseLiteral(l, false)
30+
directives := ParseDirectives(l)
3031
args = append(args, &types.Argument{
31-
Name: name,
32-
Value: value,
32+
Name: name,
33+
Value: value,
34+
Directives: directives,
3335
})
3436
}
3537
l.ConsumeToken(')')

internal/schema/meta.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ var metaSrc = `
5757
# for how to access supported similar data. Formatted in
5858
# [Markdown](https://daringfireball.net/projects/markdown/).
5959
reason: String = "No longer supported"
60-
) on FIELD_DEFINITION | ENUM_VALUE
60+
) on FIELD_DEFINITION | ENUM_VALUE | ARGUMENT_DEFINITION
6161
6262
# Provides a scalar specification URL for specifying the behavior of custom scalar types.
6363
directive @specifiedBy(

types/argument.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ package types
44
//
55
// https://spec.graphql.org/draft/#sec-Language.Arguments
66
type Argument struct {
7-
Name Ident
8-
Value Value
7+
Name Ident
8+
Value Value
9+
Directives DirectiveList
910
}
1011

1112
// ArgumentList is a collection of GraphQL Arguments.

0 commit comments

Comments
 (0)