-
Notifications
You must be signed in to change notification settings - Fork 2
BA-Add-mobile-graphql-environment #164
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -65,7 +65,8 @@ export async function httpFetch( | |||||||||||||||||||
| ): Promise<GraphQLResponse> { | ||||||||||||||||||||
| const fetchOptions = getFetchOptions({ request, variables, uploadables }) | ||||||||||||||||||||
| const response = await baseAppFetch('', { | ||||||||||||||||||||
| baseUrl: process.env.NEXT_PUBLIC_RELAY_ENDPOINT, | ||||||||||||||||||||
| baseUrl: (process.env.NEXT_PUBLIC_RELAY_ENDPOINT || | ||||||||||||||||||||
| process.env.EXPO_PUBLIC_RELAY_ENDPOINT) as string, | ||||||||||||||||||||
| decamelizeRequestBodyKeys: false, | ||||||||||||||||||||
| decamelizeRequestParamsKeys: false, | ||||||||||||||||||||
| camelizeResponseDataKeys: false, | ||||||||||||||||||||
|
|
@@ -89,7 +90,8 @@ export async function httpFetch( | |||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| const wsClient = createClient({ | ||||||||||||||||||||
| url: process.env.NEXT_PUBLIC_WS_RELAY_ENDPOINT as string, | ||||||||||||||||||||
| url: (process.env.NEXT_PUBLIC_WS_RELAY_ENDPOINT || | ||||||||||||||||||||
| process.env.EXPO_PUBLIC_WS_RELAY_ENDPOINT) as string, | ||||||||||||||||||||
|
Comment on lines
+93
to
+94
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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
Suggested change
|
||||||||||||||||||||
| connectionParams: () => { | ||||||||||||||||||||
| const Authorization = getToken() | ||||||||||||||||||||
| if (!Authorization) return {} | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_ENDPOINTnorEXPO_PUBLIC_RELAY_ENDPOINTis defined.Consider adding validation:
📝 Committable suggestion