Skip to content

Commit b3511db

Browse files
dfallingclaude
andcommitted
Add environment config with prod/dev API URLs
Switches Apollo client between localhost:4000 (dev) and https://www.culpeos.com (prod) via the __DEV__ global. Also excludes codegen.ts from the app's typecheck — it's a build-time script that relies on Node globals not in the RN tsconfig. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 92300b5 commit b3511db

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

src/config/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Environment configuration. `__DEV__` is true in Metro/debug builds and
2+
// false in release builds, so dev defaults to localhost and release points
3+
// at production.
4+
5+
type EnvConfig = {
6+
apiUrl: string;
7+
graphqlUrl: string;
8+
};
9+
10+
const production: EnvConfig = {
11+
apiUrl: 'https://www.culpeos.com',
12+
graphqlUrl: 'https://www.culpeos.com/api/graphql',
13+
};
14+
15+
const development: EnvConfig = {
16+
apiUrl: 'http://localhost:4000',
17+
graphqlUrl: 'http://localhost:4000/api/graphql',
18+
};
19+
20+
export const config: EnvConfig = __DEV__ ? development : production;

src/graphql/client.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import {ApolloClient, HttpLink, InMemoryCache} from '@apollo/client';
2-
3-
// Phoenix GraphQL endpoint. Override at runtime once the backend is reachable;
4-
// kept as a constant for now so the wiring is in place.
5-
const GRAPHQL_URI = 'http://localhost:4000/api/graphql';
2+
import {config} from '../config';
63

74
export const apolloClient = new ApolloClient({
8-
link: new HttpLink({uri: GRAPHQL_URI}),
5+
link: new HttpLink({uri: config.graphqlUrl}),
96
cache: new InMemoryCache(),
107
});

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
"types": ["jest"]
55
},
66
"include": ["**/*.ts", "**/*.tsx"],
7-
"exclude": ["**/node_modules", "**/Pods"]
7+
"exclude": ["**/node_modules", "**/Pods", "codegen.ts"]
88
}

0 commit comments

Comments
 (0)