ardatan / ardatan/graphql-tools

Ability to get names of all the stitched queries in a middleware

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

Description

I am trying to implement a rate limiter for my GraphQL server. The way I am implementing is that each query will be mapped (by its name) to a rate limit configuration. This enables me to configure each GraphQL query differently to throttle it.

Using the `info` object in a middleware, I was able to get the name of the main query, but I was not able to see the name of the stitched query (or queries).

If there was a way to get the name of the stitched queries from `info` object, or, via any other mechanism, it'd be good.

So, I have checked the documentation, tried `info` object in the middleware. Nothing has worked for me, so far.

Example:
```
{
locations {
name
reviewsForLocation {
rating
}
}
}
```

Here, the main query is `locations` and the stitched query is `reviewsForLocation`. I'd like to get the name of both the queries (types) in the middleware.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how middleware receives the `info` object and how schema stitching represents nested stitched queries. The issue names no source files or tests, so first locate the middleware and stitching entry points and check existing documentation for `info`. Done means middleware can access the names of both the main query and stitched queries in the example.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, typescript
Domain
api
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.