mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 04:24:35 +03:00
4cf13762e2
Issue: https://github.com/hasura/graphql-engine/issues/7520 Problem: add support for network metadata object Solution: add new network.yaml which consists of network metadata and in code add new network metadata object Metadata.json ``` { "resource_version": 6, "metadata": { "version": 3, "sources": [ { "name": "default", "kind": "postgres", "tables": [], "configuration": { "connection_info": { "use_prepared_statements": true, "database_url": { "from_env": "HASURA_GRAPHQL_DATABASE_URL" }, "isolation_level": "read-committed", "pool_settings": { "connection_lifetime": 600, "retries": 1, "idle_timeout": 180, "max_connections": 50 } } } } ], "network": { "tls_allowlist": [ { "suffix": null, "permissions": [ "self-signed" ], "host": "www.google.com" }, { "suffix": null, "permissions": [ "self-signed" ], "host": "play.golang.com" }, { "suffix": null, "permissions": [ "self-signed" ], "host": "hasura.io" } ] } } } ``` network.yaml ``` tls_allowlist: - suffix: null permissions: - self-signed host: www.google.com - suffix: null permissions: - self-signed host: play.golang.com - suffix: null permissions: - self-signed host: hasura.io ``` https://github.com/hasura/graphql-engine-mono/pull/2343 GitOrigin-RevId: ef508ae946dc5c7c5bcb4a9a3ccb982394ae8639
69 lines
3.2 KiB
Go
69 lines
3.2 KiB
Go
package projectmetadata
|
|
|
|
import (
|
|
"github.com/hasura/graphql-engine/cli/v2"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/actions"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/allowlist"
|
|
apilimits "github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/api_limits"
|
|
crontriggers "github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/cron_triggers"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/functions"
|
|
graphqlschemaintrospection "github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/graphql_schema_introspection"
|
|
inheritedroles "github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/inherited_roles"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/network"
|
|
querytags "github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/query_tags"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/querycollections"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/remoteschemas"
|
|
restendpoints "github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/rest_endpoints"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/sources"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/tables"
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/metadataobject/version"
|
|
)
|
|
|
|
func GetMetadataObjectsWithDir(ec *cli.ExecutionContext, dir ...string) metadataobject.Objects {
|
|
var metadataDir string
|
|
if len(dir) == 0 {
|
|
metadataDir = ec.MetadataDir
|
|
} else {
|
|
metadataDir = dir[0]
|
|
}
|
|
ec.Version.GetServerFeatureFlags()
|
|
objects := make(metadataobject.Objects, 0)
|
|
if ec.Config.Version >= cli.V2 && metadataDir != "" {
|
|
// hasura core metadata objects
|
|
if ec.HasMetadataV3 {
|
|
if ec.Config.Version >= cli.V3 {
|
|
objects = append(objects, version.New(ec, metadataDir))
|
|
objects = append(objects, sources.New(ec, metadataDir))
|
|
} else {
|
|
objects = append(objects, version.NewV3MetadataVersion(ec, metadataDir))
|
|
objects = append(objects, tables.NewV3MetadataTableConfig(ec, metadataDir))
|
|
objects = append(objects, functions.NewV3MetadataFunctionConfig(ec, metadataDir))
|
|
}
|
|
} else {
|
|
objects = append(objects, version.New(ec, metadataDir))
|
|
objects = append(objects, tables.New(ec, metadataDir))
|
|
objects = append(objects, functions.New(ec, metadataDir))
|
|
}
|
|
objects = append(objects, remoteschemas.New(ec, metadataDir))
|
|
objects = append(objects, querycollections.New(ec, metadataDir))
|
|
objects = append(objects, allowlist.New(ec, metadataDir))
|
|
objects = append(objects, actions.New(ec, metadataDir))
|
|
objects = append(objects, crontriggers.New(ec, metadataDir))
|
|
objects = append(objects, network.New(ec, metadataDir))
|
|
|
|
if ec.HasMetadataV3 && ec.Config.Version >= cli.V3 {
|
|
// metadata objects supported in metadata v3
|
|
objects = append(objects, restendpoints.New(ec, metadataDir))
|
|
objects = append(objects, inheritedroles.New(ec, metadataDir))
|
|
|
|
// hasura pro specific metadata objects
|
|
objects = append(objects, apilimits.New(ec, metadataDir))
|
|
objects = append(objects, graphqlschemaintrospection.New(ec, metadataDir))
|
|
objects = append(objects, querytags.New(ec, metadataDir))
|
|
}
|
|
}
|
|
|
|
return objects
|
|
}
|