Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions graphql/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ In addition to all environment variables supported by `@pgpmjs/env`, this packag
- `FEATURES_POSTGIS` - Enable PostGIS support

### API Configuration
- `API_ENABLE_META` - Enable meta API
- `API_ENABLE_SERVICES` - Enable services API (domain/subdomain routing)
- `API_IS_PUBLIC` - Whether API is public
- `API_EXPOSED_SCHEMAS` - Comma-separated list of exposed schemas
- `API_META_SCHEMAS` - Comma-separated list of meta schemas
Expand All @@ -59,7 +59,7 @@ GraphQL defaults are provided by `@constructive-io/graphql-types`:
postgis: true
},
api: {
enableMetaApi: true,
enableServicesApi: true,
exposedSchemas: [],
anonRole: 'administrator',
roleName: 'administrator',
Expand Down
7 changes: 6 additions & 1 deletion graphql/env/__tests__/__snapshots__/merge.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exports[`getEnvOptions merges pgpm defaults, graphql defaults, config, env, and
"api": {
"anonRole": "env_anon",
"defaultDatabaseId": "override_db",
"enableMetaApi": false,
"enableServicesApi": false,
"exposedSchemas": [
"public",
"app",
Expand Down Expand Up @@ -60,6 +60,11 @@ exports[`getEnvOptions merges pgpm defaults, graphql defaults, config, env, and
"usePlan": true,
"useTx": true,
},
"errorOutput": {
"maxLength": 10000,
"queryHistoryLimit": 30,
"verbose": false,
},
"features": {
"oppositeBaseNames": false,
"postgis": false,
Expand Down
6 changes: 3 additions & 3 deletions graphql/env/__tests__/merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('getEnvOptions', () => {
simpleInflection: false
},
api: {
enableMetaApi: false,
enableServicesApi: false,
isPublic: false,
metaSchemas: ['config_meta']
}
Expand All @@ -46,7 +46,7 @@ describe('getEnvOptions', () => {
GRAPHILE_SCHEMA: 'env_schema_a,env_schema_b',
FEATURES_SIMPLE_INFLECTION: 'true',
FEATURES_POSTGIS: 'false',
API_ENABLE_META: 'true',
API_ENABLE_SERVICES: 'true',
API_IS_PUBLIC: 'true',
API_EXPOSED_SCHEMAS: 'public,app',
API_META_SCHEMAS: 'env_meta1,env_meta2',
Expand All @@ -73,7 +73,7 @@ describe('getEnvOptions', () => {
oppositeBaseNames: false
},
api: {
enableMetaApi: false,
enableServicesApi: false,
defaultDatabaseId: 'override_db'
}
},
Expand Down
4 changes: 2 additions & 2 deletions graphql/env/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const getGraphQLEnvVars = (env: NodeJS.ProcessEnv = process.env): Partial
FEATURES_OPPOSITE_BASE_NAMES,
FEATURES_POSTGIS,

API_ENABLE_META,
API_ENABLE_SERVICES,
API_IS_PUBLIC,
API_EXPOSED_SCHEMAS,
API_META_SCHEMAS,
Expand All @@ -43,7 +43,7 @@ export const getGraphQLEnvVars = (env: NodeJS.ProcessEnv = process.env): Partial
...(FEATURES_POSTGIS && { postgis: parseEnvBoolean(FEATURES_POSTGIS) }),
},
api: {
...(API_ENABLE_META && { enableMetaApi: parseEnvBoolean(API_ENABLE_META) }),
...(API_ENABLE_SERVICES && { enableServicesApi: parseEnvBoolean(API_ENABLE_SERVICES) }),
...(API_IS_PUBLIC && { isPublic: parseEnvBoolean(API_IS_PUBLIC) }),
...(API_EXPOSED_SCHEMAS && { exposedSchemas: API_EXPOSED_SCHEMAS.split(',').map(s => s.trim()) }),
...(API_META_SCHEMAS && { metaSchemas: API_META_SCHEMAS.split(',').map(s => s.trim()) }),
Expand Down
2 changes: 1 addition & 1 deletion graphql/server/src/middleware/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export const createApiMiddleware = (opts: any) => {
res: Response,
next: NextFunction
): Promise<void> => {
if (opts.api?.enableMetaApi === false) {
if (opts.api?.enableServicesApi === false) {
const schemas = opts.api.exposedSchemas;
const anonRole = opts.api.anonRole;
const roleName = opts.api.roleName;
Expand Down
2 changes: 1 addition & 1 deletion graphql/types/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const config: ConstructiveOptions = {
appendPlugins: [],
},
api: {
enableMetaApi: true,
enableServicesApi: true,
exposedSchemas: ['public'],
},
features: {
Expand Down
6 changes: 3 additions & 3 deletions graphql/types/src/graphile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export interface GraphileFeatureOptions {
* Configuration options for the Constructive API
*/
export interface ApiOptions {
/** Whether to enable the meta API endpoints */
enableMetaApi?: boolean;
/** Whether to enable the services API (domain/subdomain routing via services_public) */
enableServicesApi?: boolean;
/** Database schemas to expose through the API */
exposedSchemas?: string[];
/** Anonymous role name for unauthenticated requests */
Expand Down Expand Up @@ -70,7 +70,7 @@ export const graphileFeatureDefaults: GraphileFeatureOptions = {
* Default API configuration values
*/
export const apiDefaults: ApiOptions = {
enableMetaApi: true,
enableServicesApi: true,
exposedSchemas: [],
anonRole: 'administrator',
roleName: 'administrator',
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/src/commands/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Options:
--simpleInflection Use simple inflection (default: true)
--oppositeBaseNames Use opposite base names (default: false)
--postgis Enable PostGIS extension (default: true)
--metaApi Enable Meta API (default: true)
--servicesApi Enable Services API (default: true)
--cwd <directory> Working directory (default: current directory)

Examples:
Expand Down Expand Up @@ -57,8 +57,8 @@ const questions: Question[] = [
useDefault: true
},
{
name: 'metaApi',
message: 'Enable Meta API?',
name: 'servicesApi',
message: 'Enable Services API?',
type: 'confirm',
required: false,
default: true,
Expand Down Expand Up @@ -125,7 +125,7 @@ export default async (
port,
postgis,
simpleInflection,
metaApi,
servicesApi,
origin
} = await prompter.prompt(argv, questions);

Expand All @@ -144,7 +144,7 @@ export default async (
let selectedSchemas: string[] = [];
let authRole: string | undefined;
let roleName: string | undefined;
if (!metaApi) {
if (!servicesApi) {
const db = await getPgPool({ database: selectedDb });
const result = await db.query(`
SELECT nspname
Expand Down Expand Up @@ -197,8 +197,8 @@ export default async (
postgis
},
api: {
enableMetaApi: metaApi,
...(metaApi === false && { exposedSchemas: selectedSchemas, authRole, roleName })
enableServicesApi: servicesApi,
...(servicesApi === false && { exposedSchemas: selectedSchemas, authRole, roleName })
},
server: {
port,
Expand Down