Can't add GraphQL directive on list of types

Viewed 42

I have the following code to check the ids given:

directive @check(
    type: AnEntity!
) on INPUT_FIELD_DEFINITION | ARGUMENT_DEFINITION

enum AnEntity{
    FOO,
    BAR,
}

input AnEntityInput{
    ids: [ID!]! @check(type: FOO)
}

mutation ...

When the mutation is actually run, the error from a validator was:

graphql.AssertException: The directive rule '@check' cannot be placed on elements of type '[ID!]'

id: ID! @check(type: FOO) understandably works because it is what it says in the docs, but I cannot get it to work for a list of IDs. How can I achieve that? Alternatively, what is the "location" type of a list of input fields?

0 Answers
Related