forked from cerc-io/ipld-eth-server
Merge pull request #89 from vulcanize/feature/configurableMutations
Disable default mutations is now in config file
This commit is contained in:
commit
202fb6e6a6
@ -23,8 +23,7 @@ Build the docker image in this directory. Start the `GraphiQL` frontend by:
|
|||||||
* GraphiQL frontend is available at `:3000/graphiql`
|
* GraphiQL frontend is available at `:3000/graphiql`
|
||||||
GraphQL endpoint is available at `:3000/graphql`
|
GraphQL endpoint is available at `:3000/graphql`
|
||||||
|
|
||||||
By default, this build will expose only the "public" schema - to add other schemas, use either the env variables,
|
By default, this build will expose only the "public" schema and will disable mutations - to change mutation behaviour, you can use an optional config file `config.toml` and set the env var `POSTGRAPHILE_CONFIG_PATH` to point to its location. Example `toml`:
|
||||||
or a config file `config.toml` and set the env var `CONFIG_PATH` to point to its location. Example `toml`:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
[database]
|
[database]
|
||||||
@ -34,6 +33,7 @@ or a config file `config.toml` and set the env var `CONFIG_PATH` to point to its
|
|||||||
gq_schemas = ["public", "yourschema"]
|
gq_schemas = ["public", "yourschema"]
|
||||||
gq_user = "graphql"
|
gq_user = "graphql"
|
||||||
gq_password = "graphql"
|
gq_password = "graphql"
|
||||||
|
disable_default_mutations = false
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
@ -25,7 +25,8 @@ describe('buildServerConfig', () => {
|
|||||||
host: 'example.com',
|
host: 'example.com',
|
||||||
database: 'example_database',
|
database: 'example_database',
|
||||||
schemas: ['public'],
|
schemas: ['public'],
|
||||||
ownerConnectionString: 'postgres://admin:admin@host'
|
ownerConnectionString: 'postgres://admin:admin@host',
|
||||||
|
disableDefaultMutations: true
|
||||||
};
|
};
|
||||||
|
|
||||||
postgraphileMiddleware = jasmine
|
postgraphileMiddleware = jasmine
|
||||||
|
@ -24,6 +24,7 @@ export function parseConfig(
|
|||||||
let gqSchemas = ['public'];
|
let gqSchemas = ['public'];
|
||||||
let gqUser = '';
|
let gqUser = '';
|
||||||
let gqPassword = '';
|
let gqPassword = '';
|
||||||
|
let disableDefaultMutations = true;
|
||||||
|
|
||||||
if (configPath) {
|
if (configPath) {
|
||||||
const tomlContents = readCallback(`${configPath}`).toString();
|
const tomlContents = readCallback(`${configPath}`).toString();
|
||||||
@ -37,6 +38,9 @@ export function parseConfig(
|
|||||||
gqSchemas = parsedToml['database']['gq_schemas'];
|
gqSchemas = parsedToml['database']['gq_schemas'];
|
||||||
gqUser = parsedToml['database']['gq_user'] || gqUser;
|
gqUser = parsedToml['database']['gq_user'] || gqUser;
|
||||||
gqPassword = parsedToml['database']['gq_password'] || gqPassword;
|
gqPassword = parsedToml['database']['gq_password'] || gqPassword;
|
||||||
|
disableDefaultMutations = parsedToml['database']['disable_default_mutations'] === undefined
|
||||||
|
? true
|
||||||
|
: parsedToml['database']['disable_default_mutations'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Overwrite config values with env. vars if such are set
|
// Overwrite config values with env. vars if such are set
|
||||||
@ -69,6 +73,7 @@ export function parseConfig(
|
|||||||
: `postgres://${user}:${password}@${host}:${port}`,
|
: `postgres://${user}:${password}@${host}:${port}`,
|
||||||
database,
|
database,
|
||||||
schemas: gqSchemas,
|
schemas: gqSchemas,
|
||||||
ownerConnectionString: `postgres://${user}:${password}@${host}:${port}/${database}`
|
ownerConnectionString: `postgres://${user}:${password}@${host}:${port}/${database}`,
|
||||||
|
disableDefaultMutations
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import {
|
|||||||
PostgraphileOptions
|
PostgraphileOptions
|
||||||
} from '../adapters/postgraphile';
|
} from '../adapters/postgraphile';
|
||||||
|
|
||||||
export const CONFIG_PATH_KEY = 'CONFIG_PATH';
|
export const CONFIG_PATH_KEY = 'POSTGRAPHILE_CONFIG_PATH';
|
||||||
export const SERVER_PORT_KEY = 'SERVER_PORT';
|
export const SERVER_PORT_KEY = 'SERVER_PORT';
|
||||||
|
|
||||||
const DEFAULT_SERVER_PORT = '3000';
|
const DEFAULT_SERVER_PORT = '3000';
|
||||||
@ -27,7 +27,7 @@ export function buildServerConfig(
|
|||||||
|
|
||||||
const options: PostgraphileOptions = {
|
const options: PostgraphileOptions = {
|
||||||
appendPlugins: [PgSimplifyInflectorPlugin],
|
appendPlugins: [PgSimplifyInflectorPlugin],
|
||||||
disableDefaultMutations: true,
|
disableDefaultMutations: databaseConfig.disableDefaultMutations,
|
||||||
enableCors: true,
|
enableCors: true,
|
||||||
exportGqlSchemaPath: 'schema.graphql',
|
exportGqlSchemaPath: 'schema.graphql',
|
||||||
graphiql: true,
|
graphiql: true,
|
||||||
|
@ -18,6 +18,7 @@ export interface DatabaseConfig {
|
|||||||
database: string;
|
database: string;
|
||||||
schemas: string[];
|
schemas: string[];
|
||||||
ownerConnectionString: string;
|
ownerConnectionString: string;
|
||||||
|
disableDefaultMutations: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ServerConfig {
|
export interface ServerConfig {
|
||||||
|
Loading…
Reference in New Issue
Block a user