Skip to content

Commit 6359f58

Browse files
committed
feat: separate GraphQL types into @launchql/types package
- Create new @launchql/types package (v2.11.0) with GraphQL/Graphile types - Remove postgraphile and graphile-build dependencies from @pgpmjs/types - Move GraphileOptions, ApiOptions, FeatureOptions to @launchql/types - Add EnvOptions and EnvGraphQLOptions types to @pgpmjs/env - Update consumer packages to use @launchql/types for GraphQL types - Ensures pgpm has zero GraphQL dependencies in its dependency chain Packages updated: - @pgpmjs/types: removed graphile deps, kept core PGPM types - @pgpmjs/env: added EnvOptions type for full env var parsing - @launchql/types: new package with LaunchQLOptions, GraphileOptions, etc. - @launchql/server, @launchql/explorer: use LaunchQLOptions - graphile-settings, graphile-test, launchql-test: use @launchql/types Co-Authored-By: Dan Lynch <pyramation@gmail.com>
1 parent e4d5396 commit 6359f58

23 files changed

Lines changed: 2941 additions & 7423 deletions

File tree

graphile/graphile-settings/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
},
3131
"dependencies": {
3232
"@graphile-contrib/pg-many-to-many": "^1.0.2",
33+
"@launchql/types": "workspace:^",
3334
"@pgpmjs/env": "workspace:^",
3435
"@pgpmjs/types": "workspace:^",
3536
"cors": "^2.8.5",

graphile/graphile-settings/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import PgManyToMany from '@graphile-contrib/pg-many-to-many';
22
import { getEnvOptions } from '@pgpmjs/env';
3-
import { PgpmOptions } from '@pgpmjs/types';
3+
import { LaunchQLOptions } from '@launchql/types';
44
import PgPostgis from 'graphile-postgis';
55
import FulltextFilterPlugin from 'graphile-plugin-fulltext-filter';
66
import { NodePlugin, Plugin } from 'graphile-build';
@@ -19,7 +19,7 @@ import CustomPgTypeMappingsPlugin from 'graphile-pg-type-mappings';
1919
import UploadPostGraphilePlugin, { Uploader } from 'graphile-upload-plugin';
2020

2121
export const getGraphileSettings = (
22-
rawOpts: PgpmOptions
22+
rawOpts: LaunchQLOptions
2323
): PostGraphileOptions => {
2424
const opts = getEnvOptions(rawOpts);
2525

graphile/graphile-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"makage": "^0.1.8"
3535
},
3636
"dependencies": {
37+
"@launchql/types": "workspace:^",
3738
"@pgpmjs/types": "workspace:^",
3839
"graphql": "15.10.1",
3940
"mock-req": "^0.2.0",

graphile/graphile-test/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { GraphileOptions } from '@pgpmjs/types';
1+
import type { GraphileOptions } from '@launchql/types';
22
import { DocumentNode, GraphQLError } from 'graphql';
33

44
export interface GraphQLQueryOptions<TVariables = Record<string, any>> {

packages/env/src/env.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,38 @@
11
import { PgpmOptions } from '@pgpmjs/types';
22

3+
/**
4+
* Extended env options that include GraphQL-related fields.
5+
* These fields are parsed from environment variables but typed separately
6+
* to avoid coupling @pgpmjs/types to GraphQL dependencies.
7+
*
8+
* For full type safety with GraphQL options, use LaunchQLOptions from @launchql/types
9+
*/
10+
export interface EnvGraphQLOptions {
11+
graphile?: {
12+
schema?: string | string[];
13+
};
14+
features?: {
15+
simpleInflection?: boolean;
16+
oppositeBaseNames?: boolean;
17+
postgis?: boolean;
18+
};
19+
api?: {
20+
enableMetaApi?: boolean;
21+
isPublic?: boolean;
22+
exposedSchemas?: string[];
23+
metaSchemas?: string[];
24+
anonRole?: string;
25+
roleName?: string;
26+
defaultDatabaseId?: string;
27+
};
28+
}
29+
30+
/**
31+
* Combined environment options type that includes both PGPM core options
32+
* and GraphQL-related options parsed from environment variables.
33+
*/
34+
export type EnvOptions = PgpmOptions & EnvGraphQLOptions;
35+
336
const parseEnvNumber = (val?: string): number | undefined => {
437
const num = Number(val);
538
return !isNaN(num) ? num : undefined;
@@ -10,7 +43,7 @@ const parseEnvBoolean = (val?: string): boolean | undefined => {
1043
return ['true', '1', 'yes'].includes(val.toLowerCase());
1144
};
1245

13-
export const getEnvVars = (): PgpmOptions => {
46+
export const getEnvVars = (): EnvOptions => {
1447
const {
1548
PGROOTDATABASE,
1649
PGTEMPLATE,

packages/env/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export { getEnvVars, getNodeEnv } from './env';
44
export { walkUp } from './utils';
55

66
export type { PgpmOptions, PgTestConnectionOptions, DeploymentOptions } from '@pgpmjs/types';
7+
export type { EnvOptions, EnvGraphQLOptions } from './env';

packages/env/src/merge.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import deepmerge from 'deepmerge';
22
import { pgpmDefaults, PgpmOptions, PgTestConnectionOptions, DeploymentOptions } from '@pgpmjs/types';
33
import { loadConfigSync } from './config';
4-
import { getEnvVars } from './env';
4+
import { getEnvVars, EnvOptions } from './env';
55

6-
export const getEnvOptions = (overrides: PgpmOptions = {}, cwd: string = process.cwd()): PgpmOptions => {
6+
export const getEnvOptions = (overrides: EnvOptions = {}, cwd: string = process.cwd()): EnvOptions => {
77
const defaults = pgpmDefaults;
88
const configOptions = loadConfigSync(cwd);
99
const envOptions = getEnvVars();

packages/explorer/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
},
3636
"dependencies": {
3737
"@launchql/s3-streamer": "workspace:^",
38+
"@launchql/types": "workspace:^",
3839
"@launchql/upload-names": "workspace:^",
3940
"@launchql/url-domains": "workspace:^",
4041
"@pgpmjs/env": "workspace:^",

packages/explorer/src/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { PgpmOptions } from '@pgpmjs/types';
1+
import { LaunchQLOptions } from '@launchql/types';
22
import { getEnvOptions } from '@pgpmjs/env';
33
import { getGraphileSettings as getSettings } from 'graphile-settings';
44
import { PostGraphileOptions } from 'postgraphile';
55

6-
export const getGraphileSettings = (rawOpts: PgpmOptions): PostGraphileOptions => {
6+
export const getGraphileSettings = (rawOpts: LaunchQLOptions): PostGraphileOptions => {
77
const opts = getEnvOptions(rawOpts);
88

99
const baseOptions = getSettings(opts);

packages/launchql-test/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"makage": "^0.1.8"
3535
},
3636
"dependencies": {
37+
"@launchql/types": "workspace:^",
3738
"@pgpmjs/types": "workspace:^",
3839
"graphile-settings": "workspace:^",
3940
"graphile-test": "workspace:^",

0 commit comments

Comments
 (0)