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

context missing in responseCache ifdef #6925

Open
4 tasks
mmadson opened this issue May 1, 2024 · 1 comment · May be fixed by #6927
Open
4 tasks

context missing in responseCache ifdef #6925

mmadson opened this issue May 1, 2024 · 1 comment · May be fixed by #6927

Comments

@mmadson
Copy link

mmadson commented May 1, 2024

Issue workflow progress

Progress of the issue based on the
Contributor Workflow

Make sure to fork this template and run yarn generate 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

It seems that context is not made available in the ifDef of the responseCache plugin. This seems to be inconsistent with the docs.

plugins:
  - deduplicateRequest: {}    
  - responseCache:
      includeExtensionMetadata: true
      ttl: 900000 # 15 minutes
      if: '!Object.hasOwn(context.headers, "skipCache") || context.headers.skipCache === "false"'
"Unexpected response: \"ReferenceError: context is not defined\\n    at eval (eval at enabled (/home/mmadson/redacted/node_modules/@graphql-mesh/plugin-response-cache/cjs/index.js:23:16), <anonymous>:3:23)\\n    at enabled (/home/mmadson/redacted/node_modules/@graphql-mesh/plugin-response-cache/cjs/index.js:23:47)\\n    at onRequest (/home/mmadson/redacted/node_modules/@graphql-yoga/plugin-response-cache/cjs/index.js:73:17)\\n    at /home/mmadson/dev/redacted/node_modules/@whatwg-node/server/cjs/createServerAdapter.js:55:125\\n    at iterate (/home/mmadson/dev/redacted/node_modules/@whatwg-node/server/cjs/utils.js:367:25)\\n    at iterate (/home/mmadson/redacted/node_modules/@whatwg-node/server/cjs/utils.js:379:16)\\n    at /home/mmadson/redacted/node_modules/@whatwg-node/server/cjs/utils.js:373:24\""

To Reproduce Steps to reproduce the behavior:

Expected behavior

context should be available

Environment:

  • OS: Ubuntu Linux
  • NodeJS: 20.12.2
  • NPM: 10.5.0

Additional context

package.json deps

  "dependencies": {
    "@graphql-mesh/cache-redis": "0.97.5",
    "@graphql-mesh/cli": "0.89.9",
    "@graphql-mesh/graphql": "0.97.5",
    "@graphql-mesh/mongoose": "0.97.5",
    "@graphql-mesh/openapi": "0.99.6",
    "@graphql-mesh/plugin-deduplicate-request": "0.97.5",
    "@graphql-mesh/plugin-response-cache": "0.97.6",
    "@graphql-mesh/runtime": "0.98.8",
    "@graphql-mesh/transform-encapsulate": "0.97.5",
    "@graphql-mesh/transform-extend": "0.97.5",
    "@graphql-mesh/transform-filter-schema": "0.97.5",
    "@graphql-mesh/transform-rename": "0.97.5",
    "graphql": "16.8.1",
    "mongoose": "8.3.2",
    "tslib": "2.6.2"
  },
@mmadson mmadson changed the title context context missing in responseCache ifdef May 1, 2024
@mmadson mmadson linked a pull request May 2, 2024 that will close this issue
14 tasks
@mmadson
Copy link
Author

mmadson commented May 2, 2024

turns out the main problem here is that function constructors do not inherit lexical scope. Needed to pass context as an arg to resolve things. See attached PR for a fix.

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

Successfully merging a pull request may close this issue.

1 participant