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

New Upstash Redis implementation #8350

Merged
merged 10 commits into from
Feb 11, 2025
Merged

New Upstash Redis implementation #8350

merged 10 commits into from
Feb 11, 2025

Conversation

ardatan
Copy link
Owner

@ardatan ardatan commented Jan 31, 2025

Related graphql-hive/gateway#576

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Added Upstash Redis caching implementation for GraphQL Mesh.
    • Introduced a new cache storage method for testing and configuration.
    • Added a new function for masking service ports in output.
  • Dependencies

    • Added @graphql-mesh/cache-upstash-redis package.
  • Improvements

    • Enhanced caching capabilities with dynamic cache storage configuration.
    • Implemented key-value storage operations using Upstash Redis client.
    • Updated test suite to support new caching strategies while maintaining backward compatibility.

Copy link
Contributor

coderabbitai bot commented Jan 31, 2025

📝 Walkthrough

Walkthrough

The pull request introduces a new implementation for Upstash Redis caching in the GraphQL Mesh framework. This includes the addition of the @graphql-mesh/cache-upstash-redis package, which provides a comprehensive implementation of a Redis-based cache mechanism. The changes involve creating a new package structure, implementing a cache class, updating test configurations, and adding necessary dependencies to support Upstash Redis as a caching option.

Changes

File Change Summary
.changeset/sixty-rivers-shave.md New changeset file for the Upstash Redis cache implementation
e2e/cache-control/cache-control.test.ts Added upstash-redis async function to cache storage options and enhanced service management
e2e/cache-control/gateway.config.ts Dynamic cache configuration with Upstash Redis support
e2e/cache-control/package.json Added @graphql-mesh/cache-upstash-redis as a dev dependency
packages/cache/upstash-redis/package.json New package configuration for Upstash Redis cache
packages/cache/upstash-redis/src/index.ts Implemented UpstashRedisCache class with key-value cache methods
package.json Added resolutions for jest-message-util package patches
e2e/utils/tenv.ts Introduced applyMaskServicePorts function for service port masking

Possibly related PRs

  • feat(redis): sentinel support #8260: The changes in the main PR, which introduce a new implementation for Upstash Redis caching, are related to the modifications in the retrieved PR that enhance Redis functionality, as both involve updates to caching mechanisms within the GraphQL Mesh framework.

Suggested reviewers

  • dotansimha

Poem

🐰 In the realm of Redis so bright,
Upstash dances with caching delight.
Mesh weaves its magical thread,
Storing secrets where data is led.
A rabbit's cache, swift and clean! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd6023e and 87bac88.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (1)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: apollo-federation-compatibility
  • GitHub Check: unit / node 22
  • GitHub Check: e2e / node v22
  • GitHub Check: unit / node 20
  • GitHub Check: integration / node 22
  • GitHub Check: e2e / node v20
  • GitHub Check: integration / node 20
  • GitHub Check: release / snapshot
  • GitHub Check: unit / node 18
  • GitHub Check: e2e / node v18
  • GitHub Check: integration / node 18
  • GitHub Check: check
  • GitHub Check: deployment
  • GitHub Check: Analyze (javascript-typescript)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Jan 31, 2025

Apollo Federation Subgraph Compatibility Results

Federation 1 Support Federation 2 Support
_service🟢
@key (single)🟢
@key (multi)🟢
@key (composite)🟢
repeatable @key🟢
@requires🟢
@provides🟢
federated tracing🟢
@link🟢
@shareable🟢
@tag🟢
@override🟢
@inaccessible🟢
@composeDirective🟢
@interfaceObject🟢

Learn more:

Copy link
Contributor

github-actions bot commented Jan 31, 2025

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
@graphql-mesh/cache-upstash-redis 0.0.1-alpha-20250211135218-87bac88bb9d074d4cf23c0086019ba6001e86b84 npm ↗︎ unpkg ↗︎

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (5)
packages/cache/upstash-redis/src/index.ts (1)

26-34: Optimize TTL conversion.

The TTL conversion to milliseconds could be more explicit and safer.

Consider this improvement:

   async set<T>(key: string, value: T, options?: { ttl?: number }) {
     if (options?.ttl) {
+      const ttlMs = Math.max(1, Math.floor(options.ttl * 1000));
       await this.redis.set(key, value, {
-        px: options.ttl * 1000,
+        px: ttlMs,
       });
     } else {
       await this.redis.set(key, value);
     }
   }
e2e/cache-control/gateway.config.ts (1)

7-14: Add type safety and error handling for cache configuration.

The current implementation could be more robust with proper type checking and error handling.

Consider this improvement:

+type CacheType = 'upstash-redis' | 'redis' | 'inmemory-lru';
+
+function isValidCacheType(type: string): type is CacheType {
+  return ['upstash-redis', 'redis', 'inmemory-lru'].includes(type);
+}
+
+const cacheType = process.env.CACHE_STORAGE;
+if (!cacheType || !isValidCacheType(cacheType)) {
+  throw new Error(`Invalid cache type: ${cacheType}`);
+}
+
-if (process.env.CACHE_STORAGE === 'upstash-redis') {
+if (cacheType === 'upstash-redis') {
   config.cache = new UpstashRedisCache();
 } else {
   config.cache = {
     // @ts-expect-error - We know it
-    type: process.env.CACHE_STORAGE,
+    type: cacheType,
   };
 }
e2e/cache-control/cache-control.test.ts (2)

102-102: Enhance container health check.

The current health check only verifies HTTP availability but not Redis functionality through the HTTP interface.

Consider this improvement:

-          healthcheck: ['CMD', 'curl', '-f', 'http://localhost'],
+          healthcheck: ['CMD', 'curl', '-f', 'http://localhost/health' '-H', 'Authorization: Bearer example_token'],

110-113: Add error handling for container disposal.

The disposal of containers should handle potential errors gracefully.

Consider this improvement:

   async [DisposableSymbols.asyncDispose]() {
-    await redis[DisposableSymbols.asyncDispose]();
-    await srh[DisposableSymbols.asyncDispose]();
+    try {
+      await Promise.all([
+        redis[DisposableSymbols.asyncDispose](),
+        srh[DisposableSymbols.asyncDispose](),
+      ]);
+    } catch (error) {
+      console.error('Error disposing containers:', error);
+      throw error;
+    }
   }
packages/cache/upstash-redis/package.json (1)

34-36: Consider constraining the graphql peer dependency version range.

Using "*" for the graphql peer dependency might lead to compatibility issues. Consider specifying a minimum version or version range that has been tested with this package.

-    "graphql": "*"
+    "graphql": "^16.0.0"
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 93b17fe and a30bb9a.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • .changeset/sixty-rivers-shave.md (1 hunks)
  • e2e/cache-control/cache-control.test.ts (1 hunks)
  • e2e/cache-control/gateway.config.ts (1 hunks)
  • e2e/cache-control/package.json (1 hunks)
  • packages/cache/upstash-redis/package.json (1 hunks)
  • packages/cache/upstash-redis/src/index.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .changeset/sixty-rivers-shave.md
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: e2e / node v22
  • GitHub Check: unit / node 22
  • GitHub Check: e2e / node v20
  • GitHub Check: integration / node 22
  • GitHub Check: unit / node 20
  • GitHub Check: integration / node 20
  • GitHub Check: release / snapshot
  • GitHub Check: unit / node 18
  • GitHub Check: integration / node 18
  • GitHub Check: e2e / node v18
  • GitHub Check: check
  • GitHub Check: deployment
  • GitHub Check: apollo-federation-compatibility
🔇 Additional comments (5)
e2e/cache-control/package.json (1)

8-8: Update version specification.

The version ^0.0.0 is not a proper semantic version and might cause issues with dependency resolution.

Please verify and update to a proper version number following semantic versioning.

packages/cache/upstash-redis/package.json (4)

14-32: LGTM! Excellent dual CJS/ESM support configuration.

The exports field is well-structured with proper type definitions for both CommonJS and ES modules.


44-48: LGTM! Publishing configuration is well-structured.

The publishing configuration correctly specifies public access and the dist directory, with sideEffects properly set to false for better tree-shaking.


49-51: LGTM! TypeScript configuration is consistent.

The TypeScript definition path matches the exports configuration.


37-43: Verify @upstash/redis version compatibility and security.

Let's check if version 1.34.3 of @upstash/redis is the latest stable version and if it has any known security vulnerabilities.

✅ Verification successful

@upstash/redis version 1.34.3 is verified as secure and up-to-date

The package is using the latest stable version, is actively maintained by the Upstash team, and has no known security vulnerabilities. While version 1.35.0-canary exists, it's a pre-release version not recommended for production use.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check @upstash/redis version and security advisories

# Check NPM for latest version
echo "Latest version from NPM:"
npm view @upstash/redis version

# Check for security advisories
echo -e "\nSecurity advisories:"
npm audit @upstash/[email protected]

Length of output: 539


Script:

#!/bin/bash
# Get detailed package information
echo "Package details:"
npm view @upstash/redis

# Check GitHub security advisories
echo -e "\nGitHub security advisories:"
gh api \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  /repos/upstash/upstash-redis/security-advisories

Length of output: 1184

Copy link
Contributor

github-actions bot commented Jan 31, 2025

💻 Website Preview

The latest changes are available as preview in: https://ed8d36a1.graphql-mesh.pages.dev

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
packages/cache/upstash-redis/src/index.ts (1)

10-20: ⚠️ Potential issue

Add environment variable validation.

The constructor should validate the required environment variables to prevent runtime errors.

Add validation as follows:

   constructor(config?: Partial<RedisConfigNodejs>) {
     this.abortCtrl = new AbortController();
+    const url = process.env.UPSTASH_REDIS_REST_URL;
+    const token = process.env.UPSTASH_REDIS_REST_TOKEN;
+    if (!url || !token) {
+      throw new Error('UPSTASH_REDIS_REST_URL and UPSTASH_REDIS_REST_TOKEN must be set');
+    }
     this.redis = new Redis({
-      url: process.env.UPSTASH_REDIS_REST_URL,
-      token: process.env.UPSTASH_REDIS_REST_TOKEN,
+      url,
+      token,
       enableAutoPipelining: true,
       signal: this.abortCtrl.signal,
       latencyLogging: !!process.env.DEBUG,
       ...config,
     });
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a30bb9a and d0790de.

📒 Files selected for processing (1)
  • packages/cache/upstash-redis/src/index.ts (1 hunks)
🧰 Additional context used
🪛 GitHub Check: e2e / node v22
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: e2e / node v20
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: e2e / node v18
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: apollo-federation-compatibility
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: integration / node 22
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: integration / node 20
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: integration / node 18
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: release / snapshot
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Check: deployment
packages/cache/upstash-redis/src/index.ts

[failure] 49-49:
Type 'string' is not assignable to type 'number'.

🪛 GitHub Actions: website
packages/cache/upstash-redis/src/index.ts

[error] 49-49: Type 'string' is not assignable to type 'number'

🪛 GitHub Actions: pr
packages/cache/upstash-redis/src/index.ts

[error] 49-49: Type 'string' is not assignable to type 'number'

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: unit / node 22
  • GitHub Check: unit / node 20
  • GitHub Check: unit / node 18
  • GitHub Check: check
🔇 Additional comments (4)
packages/cache/upstash-redis/src/index.ts (4)

1-9: LGTM!

The imports and class declaration are well-structured and follow best practices.


22-24: LGTM!

The get method is correctly implemented with proper type safety.


36-39: LGTM!

The delete method is correctly implemented, properly handling the Redis response.


55-57: LGTM!

The dispose method correctly implements the disposal pattern.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d0790de and 0194643.

⛔ Files ignored due to path filters (1)
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • .changeset/sixty-rivers-shave.md (1 hunks)
  • e2e/cache-control/cache-control.test.ts (1 hunks)
  • e2e/cache-control/gateway.config.ts (1 hunks)
  • e2e/cache-control/package.json (1 hunks)
  • packages/cache/upstash-redis/package.json (1 hunks)
  • packages/cache/upstash-redis/src/index.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
  • e2e/cache-control/package.json
  • .changeset/sixty-rivers-shave.md
  • e2e/cache-control/cache-control.test.ts
  • packages/cache/upstash-redis/package.json
  • packages/cache/upstash-redis/src/index.ts
⏰ Context from checks skipped due to timeout of 90000ms (13)
  • GitHub Check: unit / node 22
  • GitHub Check: unit / node 20
  • GitHub Check: e2e / node v22
  • GitHub Check: unit / node 18
  • GitHub Check: e2e / node v20
  • GitHub Check: e2e / node v18
  • GitHub Check: apollo-federation-compatibility
  • GitHub Check: check
  • GitHub Check: integration / node 22
  • GitHub Check: integration / node 20
  • GitHub Check: integration / node 18
  • GitHub Check: deployment
  • GitHub Check: release / snapshot
🔇 Additional comments (3)
e2e/cache-control/gateway.config.ts (3)

2-2: LGTM! Clean import and configuration initialization.

The import of UpstashRedisCache and empty configuration initialization look good.

Also applies to: 5-5


Line range hint 16-29: LGTM! Clear plugin configuration with proper error handling.

The logging and plugin configuration logic is well-structured with appropriate error handling for unknown plugin types.


8-8: 🛠️ Refactor suggestion

Add configuration options and error handling for Redis connection.

The UpstashRedisCache is initialized without configuration options or error handling.

Please verify if UpstashRedisCache requires configuration options:

Consider adding configuration and error handling:

-config.cache = new UpstashRedisCache();
+try {
+  config.cache = new UpstashRedisCache({
+    // Add necessary configuration options based on environment variables
+    url: process.env.UPSTASH_REDIS_URL,
+    token: process.env.UPSTASH_REDIS_TOKEN,
+  });
+} catch (error) {
+  console.error('Failed to initialize Upstash Redis cache:', error);
+  throw error;
+}

ardatan and others added 5 commits February 11, 2025 15:18
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
e2e/cache-control/gateway.config.ts (1)

7-14: ⚠️ Potential issue

Add type safety and environment variable validation.

The current implementation has several areas for improvement:

  1. Using type assertion is unsafe and can lead to runtime errors
  2. Missing validation for CACHE_STORAGE environment variable

Consider this safer implementation:

+const VALID_CACHE_TYPES = ['upstash-redis', 'memory', 'redis'] as const;
+type CacheType = typeof VALID_CACHE_TYPES[number];
+
+const cacheStorage = process.env.CACHE_STORAGE as string;
+
+if (!VALID_CACHE_TYPES.includes(cacheStorage as CacheType)) {
+  throw new Error(`Invalid cache storage type: ${cacheStorage}. Valid types are: ${VALID_CACHE_TYPES.join(', ')}`);
+}
+
-if (process.env.CACHE_STORAGE === 'upstash-redis') {
+if (cacheStorage === 'upstash-redis') {
   config.cache = new UpstashRedisCache();
 } else {
   config.cache = {
-    type: process.env.CACHE_STORAGE as 'redis',
+    type: cacheStorage as CacheType,
   };
 }
🧹 Nitpick comments (2)
e2e/cache-control/gateway.config.ts (2)

1-5: Add environment variable validation.

Consider validating required environment variables early to fail fast and provide clear error messages.

 import { defineConfig } from '@graphql-hive/gateway';
 import UpstashRedisCache from '@graphql-mesh/cache-upstash-redis';
 import useHTTPCache from '@graphql-mesh/plugin-http-cache';
 
+if (!process.env.CACHE_STORAGE) {
+  throw new Error('CACHE_STORAGE environment variable is required');
+}
+if (!process.env.CACHE_PLUGIN) {
+  throw new Error('CACHE_PLUGIN environment variable is required');
+}
+
 const config: ReturnType<typeof defineConfig> = {};

15-26: Replace console.log with proper logging.

Using console.log for configuration information is not recommended in production code. Consider using a proper logging library that supports different log levels and structured logging.

+import { logger } from './logger'; // Add proper logging setup
+
-console.log(`Using cache storage: ${process.env.CACHE_STORAGE}`);
+logger.info('Cache configuration', { storage: process.env.CACHE_STORAGE });
 
-console.log(`Using cache plugin: ${process.env.CACHE_PLUGIN}`);
+logger.info('Plugin configuration', { plugin: process.env.CACHE_PLUGIN });
 
 if (process.env.CACHE_PLUGIN === 'HTTP Caching') {
   config.plugins = ctx => [useHTTPCache(ctx)];
 } else if (process.env.CACHE_PLUGIN === 'Response Caching') {
   config.responseCaching = {
     session: () => null,
   };
 } else {
-  throw new Error(`Unknown caching plugin: ${process.env.CACHE_PLUGIN}`);
+  logger.error('Invalid plugin configuration', { plugin: process.env.CACHE_PLUGIN });
+  throw new Error(`Unknown caching plugin: ${process.env.CACHE_PLUGIN}`);
 }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 370c8eb and 80b7ea5.

📒 Files selected for processing (1)
  • e2e/cache-control/gateway.config.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (14)
  • GitHub Check: e2e / node v22
  • GitHub Check: e2e / node v20
  • GitHub Check: e2e / node v18
  • GitHub Check: unit / node 22
  • GitHub Check: integration / node 22
  • GitHub Check: unit / node 20
  • GitHub Check: apollo-federation-compatibility
  • GitHub Check: integration / node 20
  • GitHub Check: unit / node 18
  • GitHub Check: release / snapshot
  • GitHub Check: integration / node 18
  • GitHub Check: deployment
  • GitHub Check: check
  • GitHub Check: Analyze (javascript-typescript)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
e2e/cache-control/gateway.config.ts (2)

7-29: Improve type safety for cache storage configuration.

While the validation logic is good, we can further improve type safety:

-const VALID_CACHE_STORAGES = ['upstash-redis', 'inmemory-lru', 'redis'];
+const VALID_CACHE_STORAGES = ['upstash-redis', 'inmemory-lru', 'redis'] as const;
+type CacheStorageType = typeof VALID_CACHE_STORAGES[number];

-const cacheStorage = process.env.CACHE_STORAGE;
+const cacheStorage = process.env.CACHE_STORAGE as string;

 if (cacheStorage === 'upstash-redis') {
   config.cache = new UpstashRedisCache();
 } else {
   config.cache = {
-    type: cacheStorage as 'redis',
+    type: cacheStorage as CacheStorageType,
   };
 }

30-49: Improve type safety for cache plugin configuration.

Similar to the cache storage configuration, we can improve type safety:

-const VALID_CACHE_PLUGINS = ['HTTP Caching', 'Response Caching'];
+const VALID_CACHE_PLUGINS = ['HTTP Caching', 'Response Caching'] as const;
+type CachePluginType = typeof VALID_CACHE_PLUGINS[number];

-const cachePlugin = process.env.CACHE_PLUGIN;
+const cachePlugin = process.env.CACHE_PLUGIN as string;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80b7ea5 and 9eaf8b0.

⛔ Files ignored due to path filters (1)
  • .yarn/patches/jest-message-util-npm-29.7.0-7f88b6e8d1.patch is excluded by !**/.yarn/**
📒 Files selected for processing (3)
  • e2e/cache-control/cache-control.test.ts (1 hunks)
  • e2e/cache-control/gateway.config.ts (1 hunks)
  • package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • e2e/cache-control/cache-control.test.ts
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
e2e/cache-control/gateway.config.ts (3)

1-6: LGTM!

Clean initialization with proper imports and type safety using ReturnType.


46-48: Verify the session callback implementation.

The session callback always returns null. Please verify if this is the intended behavior or if it should be implementing some session-based logic.


52-53: LGTM!

The config export is properly typed using defineConfig.

package.json (1)

124-126: LGTM!

The resolutions ensure consistent behavior across different versions of jest-message-util by applying the same patch.

@ardatan ardatan requested a review from dotansimha February 11, 2025 13:45
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
e2e/utils/tenv.ts (1)

822-827: Add TypeScript type annotations for better type safety.

Consider adding explicit type annotations to improve type safety and code documentation.

-export function applyMaskServicePorts(result: string, subgraphs: Service[]) {
+export function applyMaskServicePorts(result: string, subgraphs: Service[]): string {
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9eaf8b0 and fd6023e.

⛔ Files ignored due to path filters (1)
  • e2e/cache-control/__snapshots__/cache-control.test.ts.snap is excluded by !**/*.snap
📒 Files selected for processing (1)
  • e2e/utils/tenv.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
e2e/utils/tenv.ts (1)

349-350: LGTM! Good refactoring of port masking logic.

The extraction of port masking logic into a separate function improves code organization and maintainability.

@ardatan ardatan requested a review from dotansimha February 11, 2025 14:11
@ardatan ardatan merged commit 40673d5 into master Feb 11, 2025
18 of 19 checks passed
@ardatan ardatan deleted the upstash-redis branch February 11, 2025 14:58
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 this pull request may close these issues.

2 participants