I'm trying to add permissions to certain fields that are returned from a Query.
For example, lets say I have the following structure:
type Query {
stores: [Store],
managers: [Manager]
}
type Store {
id: ID
name: String
logo: String
}
md5-ad68507686580ca837d145c0884ec212
type Manager {
id: ID
name: String
store: Store
}
md5-b0a31d2bd6d8c69699c187f98bf3b9a8
shield({
Query: {
'*': deny,
stores: allow,
managers: {
logo: deny
}
}
});
md5-02217831918d56364b5c2714a4af1ba5
const isAllowed = rule({ cache: 'no_cache' })(
async (parent, args, ctx, info) => {
if(info.operation.selectionSet.selections[0].name.value === 'managers' && info.fieldName === 'logo'){
return false;
}
return true;
},
);
But I don't think going into the operation.selectionSet.selections is the best approach.
Is there a better approach for what I'm trying to accomplish?
Thanks a lot for your time!
Hey @xrofa :wave:,
Thank you for opening an issue. We will get back to you as soon as we can. Also, check out our Open Collective and consider contributing financially.
https://opencollective.com/graphql-shield
PS.: We offer
prioritysupport for all financial contributors. Don't forget to addprioritylabel once you start contributing :smile:
I face exactly the same problem
Most helpful comment
I face exactly the same problem