graphql-go / graphql-go/graphql
Enum as Directive Argument Causes Introspection Error
- Dominant language
- Go
- Stars
- 10.1k
- Forks
- 845
- PR merge metrics
- No merged PRs in 30d
Description
I'm trying to implement a custom directive with the schema definition:
`directive @authenticated(type: AuthenticationType) on FIELD_DEFINITION`
and I've create the `enum` and `directive` objects like so...
```go
var AuthenticationTypeEnum = graphql.NewEnum(graphql.EnumConfig{
Name: "AuthenticationType",
Values: graphql.EnumValueConfigMap{
"API_KEY": &graphql.EnumValueConfig{Value: util.AuthenticationTypeAPIKey},
"JWT": &graphql.EnumValueConfig{Value: util.AuthenticationTypeJWT},
},
})
var AuthenticatedDirective = graphql.NewDirective(graphql.DirectiveConfig{
Name: "authenticated",
Description: "Identifies a query or mutation as requiring authentication for resolution",
Locations: []string{graphql.DirectiveLocationFieldDefinition},
Args: graphql.FieldConfigArgument{
"type": &graphql.ArgumentConfig{
Type: graphql.NewNonNull(AuthenticationTypeEnum),
},
},
})
```
This issue is there's no way to attach the directive to a field definition object or implement the logic for processing it and when I go into `GraphiQL` to inspect it, the error below comes up continuously saying that the `enum` is an invalid or incomplete definition.

Has anyone encountered or resolved this before?
Contributor guide
Assessment
This issue has not been assessed yet.