Is there a way to create custom directives? I was looking to implement authentication using directives by following this blog post, but could not figure out how to define a custom directive from the source code or godocs.
Here is an example from the blog post.
type Vehicle {
id: ID!
year: Int!
make: String!
model: Int!
askingPrice: Float
costBasis: Float @hasRole(role: “MANAGER”)
numberOfOffers: Int @isAuthenticated
}
It would be nice to be able to define an isAuthenticated directive that will determine whether or not a field should resolve.
Is there currently a way to implement this?
currently, i think graphql-go only supports '''include''' and '''skip''' directives.
@1046102779 do you know if there are any examples of using the include or skip directives in a graphql.ObjectConfig?
Hi guys, any news on this? The example @conord33 provided shows how useful directives are. Looking forward to seeing custom directives in this package.
I'm working on a go version of makeExecutableSchema that might help with this https://github.com/bhoriuchi/graphql-go-tools.
Any news or progress on when graphql-go/graphql is going to support custom directives? I see in the godocs you can create new directives but there's nothing about implementing the logic for them anywhere.
I do not understand why the lib is restrictive about creating custom directives.
// SpecifiedRules The full list of specified directives.
var SpecifiedDirectives = []*Directive{
IncludeDirective,
SkipDirective,
DeprecatedDirective,
}
Most helpful comment
Any news or progress on when
graphql-go/graphqlis going to support custom directives? I see in the godocs you can create new directives but there's nothing about implementing the logic for them anywhere.