Skip to content

Conversation

@ficast
Copy link
Contributor

@ficast ficast commented Dec 20, 2024

  • graphql package update - v 1.1.14
    • Add graphql support to Expo/Mobile environment

Summary by CodeRabbit

  • New Features
    • Updated changelogs for multiple packages to reflect new version entries and dependency changes.
  • Bug Fixes
    • Enhanced flexibility in endpoint configuration for GraphQL HTTP and WebSocket connections.
  • Chores
    • Incremented version numbers for @baseapp-frontend/components, @baseapp-frontend/graphql, and @baseapp-frontend/wagtail packages.

@changeset-bot
Copy link

changeset-bot bot commented Dec 20, 2024

⚠️ No Changeset found

Latest commit: 4b4fce4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link

coderabbitai bot commented Dec 20, 2024

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 eslint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

packages/graphql/config/environment.ts

Oops! Something went wrong! :(

ESLint: 8.57.1

Error: Cannot read config file: /packages/graphql/.eslintrc.js
Error: Cannot find module '@baseapp-frontend/config/.eslintrc.js'
Require stack:

  • /packages/graphql/.eslintrc.js
  • /node_modules/.pnpm/@eslint+eslintrc@2.1.4/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli-engine/cli-engine.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/eslint.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/eslint/index.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/lib/cli.js
  • /node_modules/.pnpm/eslint@8.57.1/node_modules/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1248:15)
    at Module._load (node:internal/modules/cjs/loader:1074:27)
    at TracingChannel.traceSync (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
    at Module.require (node:internal/modules/cjs/loader:1339:12)
    at require (node:internal/modules/helpers:135:16)
    at Object. (/packages/graphql/.eslintrc.js:1:18)
    at Module._compile (node:internal/modules/cjs/loader:1546:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
    at Module.load (node:internal/modules/cjs/loader:1317:32)

Walkthrough

This pull request involves version updates across multiple packages in the @baseapp-frontend ecosystem. The primary changes include version increments for @baseapp-frontend/components (0.0.35), @baseapp-frontend/graphql (1.1.14), and @baseapp-frontend/wagtail (1.0.9). The most significant modification is in the GraphQL package's environment configuration, which adds support for Expo/Mobile environments by introducing fallback environment variables for relay endpoints.

Changes

File Change Summary
packages/components/CHANGELOG.md Updated to version 0.0.35, noting dependency update for @baseapp-frontend/graphql to 1.1.14
packages/components/package.json Version bumped from 0.0.34 to 0.0.35
packages/graphql/CHANGELOG.md Updated to version 1.1.14, adding GraphQL support for Expo/Mobile
packages/graphql/config/environment.ts Added fallback environment variables for Expo public relay endpoints
packages/graphql/package.json Version bumped from 1.1.13 to 1.1.14
packages/wagtail/CHANGELOG.md Updated to version 1.0.9, noting dependency update
packages/wagtail/package.json Version bumped from 1.0.8 to 1.0.9

Sequence Diagram

sequenceDiagram
    participant App
    participant GraphQLConfig
    participant Environment
    
    App->>GraphQLConfig: Request GraphQL Endpoint
    GraphQLConfig->>Environment: Check NEXT_PUBLIC Endpoints
    alt NEXT_PUBLIC Endpoints Not Found
        GraphQLConfig->>Environment: Check EXPO_PUBLIC Endpoints
    end
    Environment-->>GraphQLConfig: Return Appropriate Endpoint
    GraphQLConfig-->>App: Configure GraphQL Connection
Loading

Possibly related PRs

Suggested reviewers

  • anicioalexandre
  • Ronan-Fernandes

Poem

🐰 Endpoints dancing, version's light,
GraphQL hops with Expo's might!
Fallback paths, a clever trace,
Updating packages with rabbit grace.
Code leaps forward, version takes flight! 🚀

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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.

@sonarqubecloud
Copy link

Copy link

@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

🧹 Nitpick comments (2)
packages/graphql/CHANGELOG.md (1)

3-8: Enhance changelog entry with implementation details

While the changelog entry correctly indicates the addition of Expo/Mobile support, it would be more helpful to specify the actual changes made (i.e., the addition of fallback environment variables for relay endpoints).

Consider expanding the entry like this:

- Add graphql support to Expo/Mobile environment
+ Add graphql support to Expo/Mobile environment by introducing EXPO_PUBLIC_RELAY_ENDPOINT and EXPO_PUBLIC_WS_RELAY_ENDPOINT as fallback environment variables
packages/graphql/config/environment.ts (1)

Line range hint 1-1: Add documentation for environment setup

The file lacks documentation about the required environment variables for both Next.js and Expo environments.

Consider adding a comment block at the top of the file:

/**
 * Environment Configuration
 * 
 * Required environment variables:
 * - Next.js environment:
 *   - NEXT_PUBLIC_RELAY_ENDPOINT: GraphQL HTTP endpoint
 *   - NEXT_PUBLIC_WS_RELAY_ENDPOINT: GraphQL WebSocket endpoint
 * 
 * - Expo environment:
 *   - EXPO_PUBLIC_RELAY_ENDPOINT: GraphQL HTTP endpoint
 *   - EXPO_PUBLIC_WS_RELAY_ENDPOINT: GraphQL WebSocket endpoint
 */
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0ec8ff1 and 4b4fce4.

📒 Files selected for processing (7)
  • packages/components/CHANGELOG.md (1 hunks)
  • packages/components/package.json (1 hunks)
  • packages/graphql/CHANGELOG.md (1 hunks)
  • packages/graphql/config/environment.ts (2 hunks)
  • packages/graphql/package.json (1 hunks)
  • packages/wagtail/CHANGELOG.md (1 hunks)
  • packages/wagtail/package.json (1 hunks)
✅ Files skipped from review due to trivial changes (5)
  • packages/graphql/package.json
  • packages/wagtail/package.json
  • packages/components/package.json
  • packages/wagtail/CHANGELOG.md
  • packages/components/CHANGELOG.md
🔇 Additional comments (1)
packages/graphql/config/environment.ts (1)

68-69: Verify environment variable usage across the codebase

Let's ensure that the new Expo environment variables are properly documented and used consistently across the codebase.

Also applies to: 93-94

✅ Verification successful

Based on the provided context, I can see that the environment variables NEXT_PUBLIC_RELAY_ENDPOINT, EXPO_PUBLIC_RELAY_ENDPOINT, NEXT_PUBLIC_WS_RELAY_ENDPOINT, and EXPO_PUBLIC_WS_RELAY_ENDPOINT are used consistently across the codebase. The search results show that:

  1. The environment variables are properly used in the GraphQL configuration (packages/graphql/config/environment.ts)
  2. They are correctly set in webpack configurations for development environments
  3. They are used in Cypress configurations for testing
  4. The variables follow a consistent naming pattern (NEXT_PUBLIC_* for Next.js and EXPO_PUBLIC_* for Expo)

Since the environment variables are properly documented in the code and used consistently across the codebase, I can generate the final response:

Environment variables are properly configured and used consistently

The new Expo environment variables are correctly implemented alongside their Next.js counterparts, maintaining consistency across the codebase. The variables are properly used in:

  • GraphQL configuration for both HTTP and WebSocket endpoints
  • Development webpack configurations
  • Testing configurations
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for environment variable usage and documentation

# Check for environment variable usage
echo "Checking for environment variable usage..."
rg "EXPO_PUBLIC_RELAY_ENDPOINT|NEXT_PUBLIC_RELAY_ENDPOINT|EXPO_PUBLIC_WS_RELAY_ENDPOINT|NEXT_PUBLIC_WS_RELAY_ENDPOINT"

# Check for environment documentation in README or similar files
echo -e "\nChecking for environment documentation..."
fd -t f "README|\.env|\.env\.example" -x cat {}

Length of output: 47317

Comment on lines +68 to +69
baseUrl: (process.env.NEXT_PUBLIC_RELAY_ENDPOINT ||
process.env.EXPO_PUBLIC_RELAY_ENDPOINT) as string,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation for required environment variables

The current implementation silently casts potentially undefined environment variables to string. This could lead to runtime errors if neither NEXT_PUBLIC_RELAY_ENDPOINT nor EXPO_PUBLIC_RELAY_ENDPOINT is defined.

Consider adding validation:

-    baseUrl: (process.env.NEXT_PUBLIC_RELAY_ENDPOINT ||
-      process.env.EXPO_PUBLIC_RELAY_ENDPOINT) as string,
+    baseUrl: (() => {
+      const endpoint = process.env.NEXT_PUBLIC_RELAY_ENDPOINT || process.env.EXPO_PUBLIC_RELAY_ENDPOINT;
+      if (!endpoint) {
+        throw new Error('Missing required environment variable: NEXT_PUBLIC_RELAY_ENDPOINT or EXPO_PUBLIC_RELAY_ENDPOINT');
+      }
+      return endpoint;
+    })(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
baseUrl: (process.env.NEXT_PUBLIC_RELAY_ENDPOINT ||
process.env.EXPO_PUBLIC_RELAY_ENDPOINT) as string,
baseUrl: (() => {
const endpoint = process.env.NEXT_PUBLIC_RELAY_ENDPOINT || process.env.EXPO_PUBLIC_RELAY_ENDPOINT;
if (!endpoint) {
throw new Error('Missing required environment variable: NEXT_PUBLIC_RELAY_ENDPOINT or EXPO_PUBLIC_RELAY_ENDPOINT');
}
return endpoint;
})(),

Comment on lines +93 to +94
url: (process.env.NEXT_PUBLIC_WS_RELAY_ENDPOINT ||
process.env.EXPO_PUBLIC_WS_RELAY_ENDPOINT) as string,
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add validation for WebSocket endpoint

Similar to the HTTP endpoint, the WebSocket endpoint should validate that at least one environment variable is defined.

Consider adding validation:

-  url: (process.env.NEXT_PUBLIC_WS_RELAY_ENDPOINT ||
-    process.env.EXPO_PUBLIC_WS_RELAY_ENDPOINT) as string,
+  url: (() => {
+    const wsEndpoint = process.env.NEXT_PUBLIC_WS_RELAY_ENDPOINT || process.env.EXPO_PUBLIC_WS_RELAY_ENDPOINT;
+    if (!wsEndpoint) {
+      throw new Error('Missing required environment variable: NEXT_PUBLIC_WS_RELAY_ENDPOINT or EXPO_PUBLIC_WS_RELAY_ENDPOINT');
+    }
+    return wsEndpoint;
+  })(),
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
url: (process.env.NEXT_PUBLIC_WS_RELAY_ENDPOINT ||
process.env.EXPO_PUBLIC_WS_RELAY_ENDPOINT) as string,
url: (() => {
const wsEndpoint = process.env.NEXT_PUBLIC_WS_RELAY_ENDPOINT || process.env.EXPO_PUBLIC_WS_RELAY_ENDPOINT;
if (!wsEndpoint) {
throw new Error('Missing required environment variable: NEXT_PUBLIC_WS_RELAY_ENDPOINT or EXPO_PUBLIC_WS_RELAY_ENDPOINT');
}
return wsEndpoint;
})(),

@anicioalexandre anicioalexandre merged commit 33a990b into master Dec 20, 2024
9 checks passed
@anicioalexandre anicioalexandre deleted the BA-Add-mobile-graphql-environment branch December 20, 2024 13:59
@coderabbitai coderabbitai bot mentioned this pull request Dec 20, 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

Successfully merging this pull request may close these issues.

3 participants