graphql-tools icon indicating copy to clipboard operation
graphql-tools copied to clipboard

Bring AddArgumentsAsVariables back

Open klippx opened this issue 3 years ago • 0 comments

Is your feature request related to a problem? Please describe.

Version 7.1.5 and earlier had a useful transform AddArgumentsAsVariables, which was removed, apparantly without a good replacement.

Describe the solution you'd like

Bring AddArgumentsAsVariables back! We have a great use case for it in our code base. Other projects in the wild is probably bound to finding it useful as well.

Describe alternatives you've considered

We own AddArgumentsAsVariables ourselves. This however means we have to maintain it and keeping it up to date with the upstream, where we think it belongs, since it is rather complex code.

Additional context

Not really related, but still: If this is merged, we have another cool Transform that can potentially be really useful in a stitching context. Lets descibe it with an example: We have a setup with BFF (gateway schema stitching) and Services (regular graphql services). A source schema has a root query which requires userId: Query { transactions(userId: String!) }. However, to avoid forging a user id, on the client, we want to extract this from a server signed JWT token. So what the BFF does is to extract userId from the graphql context (already decrypted and verified JWT token) and injects the userId with whatever value it found there. On the client side, it consumes the query by simply doing a query: query { transactions { ... } }, from the client side the schema is stripped of userId, it's not even an option. So this makes it way harder for the client to retrieve data that doesn't belong to a verified user.

klippx avatar Mar 09 '22 10:03 klippx