ardatan / ardatan/graphql-tools

Bring AddArgumentsAsVariables back

Open
#4,290 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
TypeScript
Stars
5.4k
Forks
830
Avg merge
10h 59m
Merged PRs (30d)
45

Description

**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.

Contributor guide

Open the contributing guide

Research direction

Start by locating the historical AddArgumentsAsVariables transform and its current transform entry point in graphql-tools. Compare the former behavior with the described schema-stitching use case; done means the transform is restored and supports injecting a required argument such as userId from the GraphQL context.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.