diff --git a/docs/configuration.md b/docs/configuration.md index 4762c92..31e3cd1 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -25,8 +25,17 @@ target: keep_alive: 180s schema: - path: ./schema.graphql - + # Path to a local file in which the schema can be found + path: "./schema.graphql" + # Automatically reload the schema file. + # It will reload the contents of the file referenced by the `schema.path` configuration option + # after each `schema.auto_reload.interval` has passed. + auto_reload: + # Enable automatic file reloading + enabled: "true" + # The interval in which the schema file should be reloaded + interval: 5m + persisted_operations: # Enable or disable the feature, enabled by default enabled: "true" diff --git a/docs/schema.md b/docs/schema.md new file mode 100644 index 0000000..572c559 --- /dev/null +++ b/docs/schema.md @@ -0,0 +1,34 @@ +# Schema + +`go-graphql-armor` needs to know your schema in order to perform its validations. + + + +## Configuration + +```yaml +# ... + +schema: + # Path to a local file in which the schema can be found + path: "./schema.graphql" + # Automatically reload the schema file. + # It will reload the contents of the file referenced by the `schema.path` configuration option + # after each `schema.auto_reload.interval` has passed. + auto_reload: + # Enable automatic file reloading + enabled: "true" + # The interval in which the schema file should be reloaded + interval: 5m +``` + +## Metrics + +``` +go_graphql_armor_schema_reload{state} +``` + +| `state` | Description | +|-----------|-------------------------------------------------------------| +| `failed` | Reloading the file from local disk has failed | +| `success` | The schema file was successfully reloaded from local disk | diff --git a/internal/business/schema/schema.go b/internal/business/schema/schema.go index 5cba974..58fea67 100644 --- a/internal/business/schema/schema.go +++ b/internal/business/schema/schema.go @@ -24,7 +24,7 @@ type Config struct { AutoReload struct { Enabled bool `conf:"default:true" yaml:"enabled"` Interval time.Duration `conf:"default:30s" yaml:"interval"` - } + } `yaml:"auto_reload"` } type Provider struct {