Allow custom directives
See original GitHub issueGraphQLSchema does not expose the use of custom directives. Based on the spec, the @skip
and @include
directives are required and appears to allow for custom directives.
The GraphQLSchemaConfig
type doesn’t allow a list of directives, and neither does the GraphQLSchema
allow directives through the constructor, but it is possible to set the _directives
prop on the GraphQLSchema
type, so it’s technically possible but not exposed.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:7
- Comments:11 (7 by maintainers)
Top Results From Across the Web
How to use and create custom directives in Angular
We can use attribute directives to change the style of DOM elements. These directives are also used to hide or show particular DOM...
Read more >Creating a Custom Directive • Angular - codecraft.tv
We create directives by annotating a class with the @Directive decorator. Let's create a class called CardHoverDirective and use the @Directive dectorator to ......
Read more >Custom Directives in Angular - Medium
To create a custom attribute directive you need to add a class with a Directive decorator on it which can be imported from...
Read more >How To Use Built-In and Custom Directives in Vue.js
The v-if , v-else , and v-else-if directives allow you to create conditionally rendered HTML elements, and work similarly to JavaScript's if ...
Read more >Custom Directives | Vue.js
Custom directives should only be used when the desired functionality can only be achieved via direct DOM manipulation. Prefer declarative templating using built ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closing this now as we’ve determined that user-supplied custom directives is a non-goal for graphql-js at this time.
@leebyron Hmm. This doesn’t sit well with me. Directives are a great way for graphql server administrators to provide custom functionality to their graphql users.
From the spec:
GraphQL servers define what directives they support. For each usage of a directive, the directive must be available on that server.
This seems to be that so long as a directive can be found on the server the users of graphql should be fully capable of using said directive. Hence, there ought to be a way for graphql server administrators to add/register directives.
From my review of the source it appears that when instantiating a
GraphQLSchema
you can specify custom directives as part of theGraphQLSchemaConfig#directives
config property, but there is no way to actually execute said directives (at least from what I can tell).For those looking for similar functionality and not an outdated repo, try giving https://github.com/smooth-code/graphql-directive a look. Just don’t expect this to work forever.