question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow custom directives

See original GitHub issue

GraphQLSchema 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:closed
  • Created 8 years ago
  • Reactions:7
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

13reactions
leebyroncommented, Aug 13, 2015

Closing this now as we’ve determined that user-supplied custom directives is a non-goal for graphql-js at this time.

11reactions
dschnarecommented, Dec 27, 2017

@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 the GraphQLSchemaConfig#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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found