ardatan / ardatan/graphql-mesh
The rateLimit plugin is returning data when multiple queries or fragment are requested
- Dominant language
- TypeScript
- Stars
- 3.5k
- Forks
- 363
- Avg merge
- 6h 10m
- Merged PRs (30d)
- 19
Description
### Issue workflow progress
_Progress of the issue based on the
[Contributor Workflow](https://github.com/the-guild-org/Stack/blob/master/CONTRIBUTING.md#a-typical-contributor-workflow)_
- [ ] 1. The issue provides a reproduction available on
[Github](https://github.com/jmolivas/graphql-mesh-rate-limit)
[Cloudflare Deployment](https://graphql-mesh-rate-limit.octahedroid.workers.dev/graphql?query=fragment+Film+on+Film+%7B%0A++id%0A++title%0A%7D%0A%0Aquery+swapi+%7B%0A++%0A++film%28id%3A+%22ZmlsbXM6MQ%3D%3D%22%29+%7B%0A++++...Film%0A++%7D%0A++%0A++allFilms%28first%3A+3%29+%7B%0A++++films+%7B%0A++++++id%0A++++++title%0A++++%7D%0A++%7D%0A++%0A%7D%0A)
> Make sure to fork this template and run `yarn && yarn build && yarn start` in the terminal.
>
> Please make sure Mesh package versions under `package.json` matches yours.
- [ ] 2. A failing test has been provided
- [ ] 3. A local solution has been provided
- [ ] 4. A pull request is pending review
---
**Describe the bug**
The `rateLimit` plugin is returning query data of a query configured using the rateLimit plugin when multiple queries or fragment are requested.
The result contains the error message but also the data of the query.
Mesh config file: `.meshrc.yaml` contents
```
serve:
playground: true
browser: false
sources:
- name: SWAPI
handler:
graphql:
endpoint: https://swapi-graphql.netlify.app/.netlify/functions/index
plugins:
- rateLimit:
config:
# Add as many rules as you want
- type: Root
field: allFilms
max: 5 # requests limit for a time period
ttl: 30000 # time period
identifier: '{context.req.socket.remoteAddress}'
```
Dependencies at `package.json` file
```
{
"name": "graphql-mesh-rate-limit",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"build": "mesh build",
"clean": "rm -rf .mesh/",
"start": "mesh start",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@graphql-mesh/cli": "^0.82.27",
"@graphql-mesh/graphql": "^0.34.10",
"@graphql-mesh/plugin-rate-limit": "^0.2.19",
"graphql": "^16.6.0"
}
}
```
Queries and fragment
```
fragment Film on Film {
id
title
}
query swapi {
film(id: "ZmlsbXM6MQ==") {
...Film
}
allFilms(first: 3) {
films {
id
title
}
}
}
```
**To Reproduce** Steps to reproduce the behavior:
**Expected behavior**
**Environment:**
- OS:
- `@graphql-mesh/...`:
- NodeJS:
**Additional context**
ERRORING WHEN:
- Two queries using fragment

- Two queries without fragment

- Two queries and one is commented using fragment

- ERROR: One Query using fragment

SUCCESS:
- Two queries and one is commented no fragments

- One query no fragments

Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the linked graphql-mesh-rate-limit reproduction, its .meshrc.yaml rateLimit configuration, and package.json; run yarn, yarn build, and yarn start as described. Compare the single-query and multiple-query or fragment cases against the reported result, and consider the issue done when rate-limited responses no longer include query data alongside the error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- graphql, typescript
- Domain
- api, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100