fetch

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAPIKeyEnv       = "TUTONE_API_KEY"
	DefaultSchemaCacheFile = "schema.json"
)
View Source
const (
	DefaultHTTPTimeout = 30 * time.Second
	DefaultAuthHeader  = "Api-Key"
)

Variables

View Source
var Command = &cobra.Command{
	Use:   "fetch",
	Short: "Fetch GraphQL Schema",
	Long: `Fetch GraphQL Schema

Query the GraphQL server for schema and write it to a file.
`,
	Example: "tutone fetch --config configs/tutone.yaml",
	Run: func(cmd *cobra.Command, args []string) {
		Fetch(
			viper.GetString("endpoint"),
			viper.GetBool("auth.disable"),
			viper.GetString("auth.header"),
			viper.GetString("auth.api_key_env_var"),
			viper.GetString("cache.schema_file"),
			refetch,
		)
	},
}

Functions

func Fetch

func Fetch(
	endpoint string,
	disableAuth bool,
	authHeader string,
	authEnvVariableName string,
	schemaFile string,
	refetch bool,
)

Types

type AuthConfig

type AuthConfig struct {
	Disable bool
	Header  string
	APIKey  string
}

type Endpoint

type Endpoint struct {
	URL  string
	Auth AuthConfig
	HTTP HTTPConfig
}

func NewEndpoint

func NewEndpoint() *Endpoint

func (*Endpoint) Fetch

func (e *Endpoint) Fetch() (*schema.Schema, error)

Fetch returns everything we know how to get about the schema of an endpoint

func (*Endpoint) FetchSchema

func (e *Endpoint) FetchSchema() (*schema.Schema, error)

FetchSchema returns basic info about the schema

func (*Endpoint) FetchSchemaTypes

func (e *Endpoint) FetchSchemaTypes() ([]*schema.Type, error)

FetchTypes gathers all of the data types in the schema

func (*Endpoint) FetchType

func (e *Endpoint) FetchType(name string) (*schema.Type, error)

type GraphqlQuery

type GraphqlQuery struct {
	Query     string      `json:"query"`
	Variables interface{} `json:"variables"` // map[string]interface really...
}

type HTTPConfig

type HTTPConfig struct {
	Timeout time.Duration
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL