graphql-go / graphql-go/graphql

Enum as Directive Argument Causes Introspection Error

Open
#539 1 comment 0 reactions 0 assignees View on GitHub
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.

Screen Shot 2020-04-14 at 11 24 11 AM

Has anyone encountered or resolved this before?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.