graphql-go / graphql-go/graphql
Create custom directives
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 845
- PR merge metrics
- No merged PRs in 30d
Description
Is there a way to create custom directives? I was looking to implement authentication using directives by following this [blog post](https://blog.graph.cool/graphql-directive-permissions-authorization-made-easy-54c076b5368e), 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?
Contributor guide
Assessment
This issue has not been assessed yet.