Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The rateLimit plugin is returning data when multiple queries or fragment are requested #5232

Open
4 tasks
jmolivas opened this issue Mar 18, 2023 · 0 comments
Open
4 tasks

Comments

@jmolivas
Copy link

jmolivas commented Mar 18, 2023

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

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
    image

  • Two queries without fragment
    image

  • Two queries and one is commented using fragment
    image

  • ERROR: One Query using fragment
    image

SUCCESS:

  • Two queries and one is commented no fragments
    image

  • One query no fragments
    image

@jmolivas jmolivas changed the title rateLimit plugin returning data when multiple queries or fragment are requested The rateLimit plugin is returning data when multiple queries or fragment are requested Mar 19, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant