Does anyone know how I could programmatically differentiate between a graphql query and a field? I'm talking about this:
type User {
id: ID! <-- this would be a field
}
type Query {
getUsers: [User]! <-- this would be a query
}
I've tried to look at it every which way, but they are pretty much identical, both are of type FieldDefinition
and have the exact same structure. So is there a way to do this? I'm trying to write an auth schema directive that applies to both and is very similar, but it should do one thing differently if the directive was applied to a query.
If all else fails I can create two separate directives, but it would be really nice if the same directive could be reused and the consumer of it wouldn't have to worry about where it was applied to, it just worked.