Allow wildcard fields in FragmentReplacement
smkhalsa opened this issue ยท 6 comments
Assuming I have the following GraphQL type:
type AudioListen implements Activity {
id: ID!
user: User!
audio: Audio!
}
I'd like to be able to add a wildcard FragmentReplacement
export const fragmentReplacements: FragmentReplacement[] = [
{
field: '*',
fragment: '... on AudioListen { user { id } }',
},
];
So that the user ID is always fetched if any of the fields are fetched.
Hey @smkhalsa ๐,
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
priority
support for all financial contributors. Don't forget to addpriority
label once you start contributing ๐
Hey @smkhalsa,
Could you share the chunk of code where you need it? I think we just have to turn the problem around a bit to get it working.
@maticzav I'm not sure what exactly you're asking for.
As mentioned above, I'd like to be able to use the *
wildcard in FragmentReplacements so that certain fields are always included in the result.
Expanding on the above example, if I had the following query:
query {
getAudioListen(id:"123") {
id
audio {
id
}
}
}
Even though my query doesn't include any selections for user
, I'd still want the response to include the user.id
so that it can be used in a graphql-shield rule.
Each rule accepts a fragment
option that you may use to specify which fields it relies on. Based on where you use the rule, graphql-shield
will generate the fragment replacement that you later forward to server.
Check out the docs here
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.