-
Notifications
You must be signed in to change notification settings - Fork 2k
Add field directives on Info #1789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We probably want a more comprehensive solution to getting a directive on various schema definitions. I think the core idea here is right, but we'd also like to make it easy to access directives for things like type definitions with directives on them. I think this is possible to do already by grabbing the |
Fwiw graphql-tools has a getDirective method and cousins that might be helpful https://www.graphql-tools.com/docs/api/modules/utils_src#getdirective |
Here is my dirty workaround: import { getDirectives } from '@graphql-tools/utils';
function getDirectivesFromInfo(info: GraphQLResolveInfo) {
const field = info.parentType.getFields()[info.fieldName];
return getDirectives(info.schema, field);
} It's better if |
It's possible to add a new field on info with the directives of that field?
Reason:
The main reason for this is that using a
fieldResolver
it'll be possible to add some extra logic on selected fields.Example:
schema
fieldResolver
using express-graphql
Possible solution
In this method, we can get the directives from
fieldDef.astNode.directives
graphql-js/src/execution/execute.js
Lines 696 to 717 in b8eb8de
Also, if this is accepted, I can work on that
The text was updated successfully, but these errors were encountered: