Skip to content

Commit 689132b

Browse files
author
Robert Mosolgo
authored
Merge pull request #3072 from rmosolgo/directive-graphql-name
Directive graphql name
2 parents a14df9b + 72a7890 commit 689132b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

guides/type_definitions/directives.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,28 @@ class MySchema < GraphQL::Schema
5454
end
5555
```
5656

57+
And you can reference them in the query with `@directive_name(...)`:
58+
59+
```ruby
60+
query {
61+
field @directive_name {
62+
id
63+
}
64+
}
65+
```
66+
5767
{{ "GraphQL::Schema::Directive::Feature" | api_doc }} and {{ "GraphQL::Schema::Directive::Transform" | api_doc }} are included in the library as examples.
5868

69+
### Custom Name
70+
71+
By default, the directive's name is taken from the class name. You can override this with `graphql_name`, for example:
72+
73+
```ruby
74+
class Directives::IsPrivate < GraphQL::Schema::Directive
75+
graphql_name "someOtherName"
76+
end
77+
```
78+
5979
### Arguments
6080

6181
Like fields, directives may have {% internal_link "arguments", "/fields/arguments" %} :

0 commit comments

Comments
 (0)