Skip to content

Commit 72a7890

Browse files
committed
Recommend a camelized name; describe graphql_name usage
1 parent d91ef48 commit 72a7890

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

guides/type_definitions/directives.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ Custom directives extend {{ "GraphQL::Schema::Directive" | api_doc }}:
3939
```ruby
4040
# app/graphql/directives/my_directive.rb
4141
class Directives::MyDirective < GraphQL::Schema::Directive
42-
graphql_name "directive_name" # string, not symbol!
4342
description "A nice runtime customization"
4443
end
4544
```
@@ -67,6 +66,16 @@ query {
6766

6867
{{ "GraphQL::Schema::Directive::Feature" | api_doc }} and {{ "GraphQL::Schema::Directive::Transform" | api_doc }} are included in the library as examples.
6968

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+
7079
### Arguments
7180

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

0 commit comments

Comments
 (0)