Skip to content

Commit d91ef48

Browse files
author
palasha
authored
Document graphql_name configuration for custom directives.
This wasn't documented and I had to dig into the source code to find it. I tried to follow the style of the rest of the documentation, but feel free to edit however best reflects what you would want.
1 parent 70b6618 commit d91ef48

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

guides/type_definitions/directives.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ 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!
4243
description "A nice runtime customization"
4344
end
4445
```
@@ -54,6 +55,16 @@ class MySchema < GraphQL::Schema
5455
end
5556
```
5657

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

5970
### Arguments

0 commit comments

Comments
 (0)