Skip to content

Commit

Permalink
feat(persisted-ops): Clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
ldebruijn committed Aug 10, 2024
1 parent b6561d4 commit 41ecbc3
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
8 changes: 4 additions & 4 deletions cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ type Product {
`,
cfgOverrides: func(cfg *config.Config) *config.Config {
cfg.PersistedOperations.Enabled = true
cfg.PersistedOperations.Loader.Type = "disk"
cfg.PersistedOperations.Loader.Type = "local"
cfg.PersistedOperations.Loader.Location = "./"
return cfg
},
Expand Down Expand Up @@ -170,7 +170,7 @@ type Product {
cfgOverrides: func(cfg *config.Config) *config.Config {
cfg.ObfuscateUpstreamErrors = false
cfg.PersistedOperations.Enabled = true
cfg.PersistedOperations.Loader.Type = "disk"
cfg.PersistedOperations.Loader.Type = "local"
cfg.PersistedOperations.Loader.Location = "./"
cfg.PersistedOperations.RejectOnFailure = false
return cfg
Expand Down Expand Up @@ -371,7 +371,7 @@ type Product {
`,
cfgOverrides: func(cfg *config.Config) *config.Config {
cfg.PersistedOperations.Enabled = true
cfg.PersistedOperations.Loader.Type = "disk"
cfg.PersistedOperations.Loader.Type = "local"
cfg.PersistedOperations.Loader.Location = "./"
cfg.PersistedOperations.RejectOnFailure = false
cfg.ObfuscateUpstreamErrors = false
Expand Down Expand Up @@ -437,7 +437,7 @@ type Product {
`,
cfgOverrides: func(cfg *config.Config) *config.Config {
cfg.PersistedOperations.Enabled = true
cfg.PersistedOperations.Loader.Type = "disk"
cfg.PersistedOperations.Loader.Type = "local"
cfg.PersistedOperations.Loader.Location = "./"
cfg.PersistedOperations.RejectOnFailure = false
return cfg
Expand Down
27 changes: 14 additions & 13 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,23 @@ obfuscate_upstream_errors: true


persisted_operations:
# Enable or disable the feature, enabled by default
# Enable or disable the feature, disabled by default
enabled: false
# Fail unknown operations, disable this feature to allow unknown operations to reach your GraphQL API
reject_on_failure: true
# Store is the location on local disk where graphql-protect can find the persisted operations, it loads any `*.json` files on disk
store: "./store"
reload:
enabled: true
# The interval in which the local store dir is read and refreshes the internal state
interval: 5m
# The timeout for the remote operation
timeout: 10s
remote:
# Load persisted operations from a GCP Cloud Storage bucket.
# Will look at all the objects in the bucket and try to load any object with a `.json` extension
gcp_bucket: ""
# Loader decides how persisted operations are loaded, see loader chapter for more details
loader:
# Type of loader to use
type: local
# Location to load persisted operations from
location: ./store
# Whether to reload persisted operations periodically
reload:
enabled: true
# The interval in which the persisted operations are refreshed
interval: 5m0s
# The timeout for the refreshing operation
timeout: 10s

block_field_suggestions:
enabled: true
Expand Down
2 changes: 1 addition & 1 deletion docs/protections/persisted_operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ persisted_operations:
# Loader decides how persisted operations are loaded, see loader chapter for more details
loader:
# Type of loader to use
type: disk
type: local
# Location to load persisted operations from
location: ./store
# Whether to reload persisted operations periodically
Expand Down
2 changes: 1 addition & 1 deletion internal/app/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestNewConfig(t *testing.T) {
PersistedOperations: persistedoperations.Config{
Enabled: false,
Loader: persistedoperations.LoaderConfig{
Type: "disk",
Type: "local",
Location: "./store",
Reload: struct {
Enabled bool `conf:"default:true" yaml:"enabled"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Config struct {
}

type LoaderConfig struct {
Type string `conf:"default:disk" yaml:"type"`
Type string `conf:"default:local" yaml:"type"`
Location string `conf:"default:./store" yaml:"location"`
// Configuration for auto-reloading persisted operations
Reload struct {
Expand Down

0 comments on commit 41ecbc3

Please sign in to comment.